Part Number Hot Search : 
SC502 SA40CA 30B03 1E101 PN4250 DG3536 BB503C C5000
Product Description
Full Text Search
 

To Download HT56R67812 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ht56r67/ht56r668/ht56c668 ht56r678/ht56c678/ht56r688 tinypower tm a/d type with lcd 8-bit mcu rev. 1.60 1 may 21, 2012 general description these tinypower tm a/d type with lcd 8-bit high perfor - mance risc architecture microcontrollers are specifi - cally, designed for applications that interface directly to analog signals and which require an lcd or led inter - face. the devices include an integrated multi-channel an - alog to digital converter, pulse width modulation outputs and an lcd/led driver. with their fully integrated spi and i 2 c functions, design - ers are provided with a means of easy communication with external peripheral hardware. the benefits of inte - grated a/d, lcd, and pwm functions, in addition to low power consumption, high performance, i/o flexibility and low-cost, provides the device with the versatility for a wide range of products in the home appliance and in - dustrial application areas. some of these products could include electronic metering, environmental moni - toring, handheld instruments, electronically controlled tools, motor driving in addition to many others. the unique holtek tinypower technology also gives the devices extremely low current consumption characteris - tics, an extremely important consideration in the present trend for low power battery powered applications. the usual holtek mcu features such as power down and wake-up functions, oscillator options, programmable frequency divider, etc. combine to ensure user applica - tions require a minimum of external components. mask type devices, the ht56c668 and ht56c678, are also available for volume production products. features  operating voltage: f sys =100khz: 2.2v~5.5v f sys =4mhz: 2.2v~5.5v f sys =8mhz: 3.0v~5.5v f sys =12mhz: 4.5v~5.5v  operating current: f sys =1mhz at 3v, 170  a, typ.  otp program memory: 16k  16 ~ 48k16  ram data memory: 2304 8  24 to 32 bidirectional i/o lines  tinypower technology for low power operation  three pin-shared external interrupts lines  multiple programmable timer/event counters with overflow interrupt and 7-stage prescaler  external crystal, rc and 32768 xtal oscillators  fully integrated rc 32khz oscillator  externally supplied system clock option  watchdog timer function  pfd/buzzer for audio frequency generation  dual serial interfaces: spi and i 2 c  lcd and led driver function  4 operating modes: normal, slow, idle and sleep  8-channel 12-bit resolution a/d converter  4-channel 12-bit pwm outputs  low voltage reset function: 2.1v, 3.15v, 4.2v  low voltage detect function: 2.2v, 3.3v, 4.4v  bit manipulation instruction  table read instructions  63 powerful instructions  up to 0.33  s instruction cycle with 12mhz system clock at v dd =5v  multiple level subroutine nesting  all instructions executed in one or two machine cycles  power down and wake-up functions to reduce power consumption  wide range of available package types technical document  application note  ha0075e mcu reset and oscillator circuits application note
selection table most features are common to all devices, the main feature distinguishing them are program memory capacity, i/o count, stack capacity and package types. the following table summarises the main features of each device. part no. vdd program memory data memory i/o lcd timer a/d pwm stack package 8-bit 16-bit ht56r67 2.2v~ 5.5v 32k 16 23048 32 484 or 493 31 12-bit 8 12-bit4 12 52qfp 64lqfp 100lqfp ht56r668 ht56c668 2.2v~ 5.5v 16k16 23048 24 6416 or 728 31 12-bit 8 12-bit4 12 100lqfp 128qfp ht56r678 ht56c678 32k16 ht56r688 48k16 note: 1. part numbers including a c are mask version devices while r are otp devices. 2. for devices that exist in more than one package formats, the table reflects the situation for the larger package. block diagram ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 2 may 21, 2012         

 
          
         
    
        
             
 
                ! "       #        
      $ # %  &                '   (    )           )        ! "          
               
       #        $  %                          * + % # + ! % % 
&    , #    
   +  - .            +  - .       %    
pin assignment ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 3 may 21, 2012 / , 0 1 2 3 4  5 / 6 / / / , / 0 / 1 / 2 / 3 / 4 /  / 5 , 6 , / , , 0 1 0 2 0 3 0 4 0  0 5 1 1 52 62 /2 , , 0 , 1 , 2 , 3 , 4 ,  , 5 0 6 0 / 0 , 0 0         
 1 61 /1 ,1 01 1 1 21 31 4  $ 2 #    0  $ 3  $ 4  7 6 # $ 8 6  7 / # $ 8 /  7 , # $ 8 ,  7 0 # $ 8 0  7 1 # $ 8 1  7 2 # $ 8 2 .    % 6 #    6  % / #    /  % , #    ,  ! ) / 6 #  %   ! ) 5   1   0 . % %   ,   /  !   $ 6 # 7 9  $ / # 7 9  $ ,  $ 0 #  ' %  $ 1 #    ,  ! ) , 1  ! ) , 2  ! ) , 3   0 #  ! ) 1    ,   /   6 . / .  $ : . + % /  % 3 #    6  % 2 #  8  /  % 1 #  8  6  ! ) / / #  %  #  % $  ! ) / , #  ;  ! ) / 0 #    ! ) / 1 #  + ;  ! ) / 2 #   8   ! ) / 3  ! ) / 4  ! ) /   ! ) / 5  ! ) , 6  ! ) , /  ! ) , ,  ! ) , 0 1 4 1 3 1 2 1 1 1 0 1 , 1 / , / , , , 0 , 1 , 2 , 3 , 4 ,  , 5 0 6 0 / 0 , 0 0 0 1 0 2 0 3 0 4 0  0 5 1 6 3 1 3 0 3 , 3 / 3 6 2 5 2  2 4 2 3 2 2 2 1 2 0 2 , 2 / 2 6 1 5 1  / , 0 1 2 3 4  5 / 6 / / / , / 0 / 1 / 2 / 3 / 4 /  / 5 , 6          
  $ 4  7 6 # $ 8 6  7 / # $ 8 /  7 , # $ 8 ,  7 0 # $ 8 0  7 1 # $ 8 1  7 2 # $ 8 2 .    % 6 #    6  % / #    /  % , #    ,  % 0 #    0  % 1 #  8  6  % 2 #  8  /  % 3 #    6  % 4 #    /  ! ) , 1  ! ) , 2  ! ) , 3  ! ) , 4  ! ) ,   ! ) , 5   0 #  ! ) 1    ,   /   6 , / . + % , . / .  $ : . + % /  ! )   ! ) 5  ! ) / 6 #  %   ! ) / / #  %  #  % $  ! ) / , #  ; #  +  ! ) / 0 #    ! ) / 1 #  + ;  ! ) / 2 #   8   ! ) / 3  ! ) / 4  ! ) /   ! ) / 5  ! ) , 6  ! ) , /  ! ) , ,  ! ) , 0  ! ) 4  ! ) 3  ! ) 2   1   0 . % %   ,   /  !   $ 6 # 7 9  $ / # 7 9  $ ,  $ 0 #  ' %  $ 1 #    ,  $ 2 #    0  $ 3  $ 2 #    0  $ 3  $ 4  1  2  3  4  7 6 # $ 8 6  7 / # $ 8 /  7 , # $ 8 ,  7 0 # $ 8 0  7 1 # $ 8 1  7 2 # $ 8 2  7 3 # $ 8 3  7 4 # $ 8 4 .   $ .    % 6 #    6  % / #    /  % , #    ,  % 0 #    0  % 1 #  8  6  % 2 #  8  /  % 3 #    6  % 4 #    /  ! ) ,   ! ) , 5  ! ) 0 6  ! ) 0 /  ! ) 0 ,  ! ) 0 0  ! ) 0 1  ! ) 0 2  ! ) 0 3  ! ) 0 4  ! ) 0    0 #  ! ) 1    ,   /   6 , / . + % , . / .  $ : . + % /  0  ,  /  6  ! ) 0  ! ) 1  ! ) 2  ! ) 3  ! ) 4  ! )   ! ) 5  ! ) / 6 #  %   ! ) / / #  %  #  % $  ! ) / , #  ; #  +  ! ) / 0 #    ! ) / 1 #  + ;  ! ) / 2 #   8   ! ) / 3  ! ) / 4  ! ) /   ! ) / 5  ! ) , 6  ! ) , /  ! ) , ,  ! ) , 0  ! ) , 1  ! ) , 2  ! ) , 3  ! ) , 4  ! ) ,  ! ) /  ! ) 6  ! ) 1 4  ! ) 1 3  ! ) 1 2  ! ) 1 1  ! ) 1 0  ! ) 1 ,  ! ) 1 /  ! ) 1 6  ! ) 0 5   1   0 . % % .  ! ' $ . % %   ,   /  !   $ 6 # 7 9  $ / # 7 9  $ ,  $ 0 #  ' %  $ 1 #    ,           
 0 / 0 , 0 0 0 1 0 2 0 3 0 4 0  0 5 1 6 1 / 1 , 1 0 1 1 1 2 1 3 1 4 1  1 5 2 6  /  ,  0 1 2 3 4  55 65 /5 ,5 05 15 25 35 45 5 5/ 6 6  6 4 5 4  4 4 4 3 4 2 4 1 4 0 4 , 4 / 4 6 3 5 3  3 4 3 3 3 2 3 1 3 0 3 , 3 / 3 6 2 5 2  2 4 2 3 2 2 2 1 2 0 2 , 2 / / , 0 1 2 3 4  5 / 6 / / / , / 0 / 1 / 2 / 3 / 4 /  / 5 , 6 , / , , , 0 , 1 , 2 , 3 , 4 ,  , 5 0 6
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 4 may 21, 2012                                           
 / , 3/ , 4 1 / 1 , 1 0 1 1 1 2 1 3 1 4 1  1 5 2 6 1 6 2 / 2 , 2 0 / , 0 1 2 3 4  5 / 6 / / / , / 0 / 1 / 2 / 3 / 4 /  / 5 , 6 , / , , , 0 , 1 , 2 , 3 , 4 ,  , 5 0 6 0 / 0 , 0 0 0 1 0 2 0 3 0 4 0  / ,  0 5 2 1 2 2 2 3 2 4 2  2 5 3 6 3 / 3 , 3 0 3 1 / , 2 / , ,/ , 0 / , 1 / , / / , 6 / / 5 / /  / / 4 / / 3 / / 2 / / 1 / / 0 / / , / / / / / 6 / 6 5 / 6  / 6 4 / 6 3 / 6 2 / 6 1 / 6 0 / 6 , / 6 / / 6 6 5 5 5  5 4 5 3 5 2 5 1 5 0 5 , 5 / 5 6  5    4  3  2  1  0  ,  /  6 4 5 4  4 4 4 3 4 2 4 1 4 0 4 , 4 / 4 6 3 5 3  3 4 3 3 3 2  $ 2 #    0  $ 3  $ 4 8 8 8 8  7 6 # $ 8 6  7 / # $ 8 /  7 , # $ 8 ,  7 0 # $ 8 0  7 1 # $ 8 1  7 2 # $ 8 2  7 3 # $ 8 3  7 4 # $ 8 4 .   $ .    % 6 #    6  % / #    /  % , #    ,  % 0 #    0  % 1 #  8  6  % 2 #  8  /  % 3 #    6  % 4 #    / 8 8 . + %   6   /   ,   0   1   2   3   4    #  ! ) 4 /   5 #  ! ) 4 6  ! ) / 0  ! ) / 1  ! ) / 2 8 8 8 8  ! ) / 3  ! ) / 4  ! ) /   ! ) / 5  ! ) , 6  ! ) , /  ! ) , ,  ! ) , 0  ! ) , 1  ! ) , 2  ! ) , 3  ! ) , 4  ! ) ,   ! ) , 5  ! ) 0 6  ! ) 0 /  ! ) 0 ,  ! ) 0 0  ! ) 0 1  ! ) 0 2  ! ) 0 3  ! ) 0 4  ! ) 0   ! ) 0 5  ! ) 1 6  ! ) 1 /  ! ) 1 ,  ! ) 1 0 8 8 8  ! ) / ,  ! ) / /  ! ) / 6  ! ) 5  ! )   ! ) 4  ! ) 3   8  #  ! ) 2  + ; #  ! ) 1   #  ! ) 0  ; #  + #  ! ) ,  %  #  % $ #  ! ) /  %  #  ! ) 6   1   0 . % % .  ! ' $ . % %   ,   /  !   $ 6 # 7 9  $ / # 7 9  $ ,  $ 0 #  ' %  $ 1 #    ,  ! ) 1 1  ! ) 3 2  ! ) 1 3  ! ) 1 4  ! ) 1   ! ) 1 5  ! ) 2 6  ! ) 2 /  ! ) 2 ,  ! ) 2 0  ! ) 2 1  ! ) 2 2  ! ) 2 3  ! ) 2 4  ! ) 2 3  ! ) 2 5  ! ) 3 6  ! ) 3 /  ! ) 3 ,  ! ) 3 0   / 2 #  ! ) 3 1   / 1 #  ! ) 3 2   / 0 #  ! ) 3 3   / , #  ! ) 3 4   / / #  ! ) 3    / 6 #  ! ) 3 5  $ 2 #    0  $ 3  $ 4  7 6 # $ 8 6  7 / # $ 8 /  7 , # $ 8 ,  7 0 # $ 8 0  7 1 # $ 8 1  7 2 # $ 8 2  7 3 # $ 8 3  7 4 # $ 8 4 .    % 6 #    6  % / #    /  % , #    ,  % 0 #    0  % 1 #  8  6  % 2 #  8  /  % 3 #    6 . + %   6   /   ,   0   1  ! ) 1   ! ) 1 5  ! ) 2 6  ! ) 2 /  ! ) 2 ,  ! ) 2 0  ! ) 2 1  ! ) 2 2  ! ) 2 3  ! ) 2 4  ! ) 2 3  ! ) 2 5  ! ) 3 6  ! ) 3 /  ! ) 3 ,  ! ) 3 0   / 2 #  ! ) 3 1   / 1 #  ! ) 3 2   / 0 #  ! ) 3 3   / , #  ! ) 3 4   / / #  ! ) 3    / 6 #  ! ) 3 5   4   2   2  ! ) / 5  ! ) , 6  ! ) , /  ! ) , ,  ! ) , 0  ! ) , 1  ! ) , 2  ! ) , 3  ! ) , 4  ! ) ,   ! ) , 5  ! ) 0 6  ! ) 0 /  ! ) 0 ,  ! ) 0 0  ! ) 0 1  ! ) 0 2  ! ) 0 3  ! ) 0 4  ! ) 0   ! ) 0 5  ! ) 1 6  ! ) 1 /  ! ) 1 ,  ! ) 1 4                                            
  ! ) /   ! ) / 4  ! ) / 3  ! ) / 6  ! ) 5  ! )   ! ) 4  ! ) 3   8  #  ! ) 2  + ; #  ! ) 1   #  ! ) 0  ; #  + #  ! ) ,  %  #  % $ #  ! ) /  %  #  ! ) 6   1   0 . % %   ,   /  !   $ 6 # 7 9  $ / # 7 9  $ ,  $ 0 #  ' %  $ 1 #    , 0 / 0 , 0 0 0 1 0 2 0 3 0 4 0  0 5 1 6 1 / 1 , 1 0 1 1 1 2 1 3 1 4 1  1 5 2 6  /  ,  0 1 2 3 4  55 65 /5 ,5 05 15 25 35 45 5 5/ 6 6  6 4 5 4  4 4 4 3 4 2 4 1 4 0 4 , 4 / 4 6 3 5 3  3 4 3 3 3 2 3 1 3 0 3 , 3 / 3 6 2 5 2  2 4 2 3 2 2 2 1 2 0 2 , 2 / / , 0 1 2 3 4  5 / 6 / / / , / 0 / 1 / 2 / 3 / 4 /  / 5 , 6 , / , , , 0 , 1 , 2 , 3 , 4 ,  , 5 0 6
pin description the following table depicts the pins common to all devices. pin name i/o configuration option description pa0/bz pa1/bz pa2 pa3/pfd pa4/tmr2 pa5/tmr3 pa6~pa7 i/o bz/bz pfd bidirectional 8-bit input/output port. each individual bit on this port can be configured as a wake-up input using the pawu register. software instruc - tions determine if the pin is a cmos output or schmitt trigger input. a pull-high resistor can be connected to each pin using the papu register. pins pa0, pa1, pa3, pa4 and pa5 are shared with bz, bz , pfd, tmr2 and tmr3 respectively, the function of which is chosen via configuration option. pins pa0~pa3 can also be setup as open drain pins using the misc register. pb0/an0~ pb7/an7 i/o  bidirectional 8-bit input/output port. software instructions determine if the pin is a cmos output or schmitt trigger input. a pull-high resistor can be con - nected to each pin using the pbpu register. pb is pin-shared with the a/d in - put pins. the a/d inputs are selected via software instructions. once selected as an a/d input, the i/o function and pull-high resistor selections are disabled automatically. pd0/pwm0~ pd3/pwm3 pd4/int0 pd5/int1 pd6/tmr0 pd7/tmr1 i/o  bidirectional 8-bit input/output port. software instructions determine if the pin is a cmos output or schmitt trigger input. a pull-high resistor can be con - nected to each pin using the pdpu register. the pwm outputs, pwm0~pwm3, are pin shared with pins pd0~pd3, the function of which is chosen using the pwm registers. pins pd4~pd7 are pin-shared with int0, int1, tmr0 and tmr1 respectively. osc1 osc2 i o crystal or rc or ec osc1, osc2 are connected to an external rc network or external crystal, determined by configuration option, for the internal system clock. if the rc system clock option is selected, pin osc2 can be used to measure the sys- tem clock at 1/4 frequency. ec is external clock mode, we can input clock source directly to osc1 pin. osc3 osc4 i o 32768hz osc3 and osc4 are connected to a 32768hz crystal oscillator to form a real time clock for f sub . this 32768hz crystal is disabled/enabled by configuration option. vref i  a/d reference voltage input pin res i  schmitt trigger reset input. active low vdd  positive power supply vss  negative power supply, ground avdd  analog positive power supply avss  analog negative power supply, ground ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 5 may 21, 2012
the following tables depict the device dependent pins. pin name i/o configuration option description ht56r67 pc0~pc7 i/o  bidirectional 8-bit input/output port. software instructions determine the cmos output, schmitt trigger input with or without pull-high resistor (de - termined by pcpu register control bit) vmax i  ic maximum voltage, connect to v dd ,v lcd1 or v1 vlcd1/vlcd2/v1, c1, c2  lcd voltage pump pins for c-type biasing. for r-type biasing only pin vlcd1 are used. seg0~seg9 seg10/sdo seg11/sdi/sda seg12/sck/scl seg13/scs seg14/pclk seg15/pint seg16~seg47 o o i/o i/o i/o o i/o o sim pint seg0~seg47 are lcd driver outputs for lcd panel segments. seg10 is pin-shared with the spi bus data output line, sdo. seg11 is pin-shared with the spi bus data input line, sdi and the i 2 c bus data line sda. seg12 is pin-shared with the spi bus clock line, sck and the i 2 c bus clock line scl. seg13 is pin-shared with the spi bus select line, scs . seg14 is pin-shared with the peripheral clock line, pclk. seg15 is pin-shared with the peripheral interrupt line, pint . the seg0~seg23 lines can be can be chosen to be either segment driv - ers or cmos outputs using control bits in the lcd control registers. com0~com2 com3/seg48 o  com0~com2 are the lcd common outputs. a bit in the lcd control register determines if pin com3/seg48 is configured as a segment driver or as a common output driver. ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 vlcd i  lcd bias pin  must less than or equal to vdd seg0/sdo seg1/sdi/sda seg2/sck/scl seg3/scs seg4/pclk seg5/pint seg6~seg63 com15/seg64~ com8/seg71 o i/o i/o i/o o i/o o o sim pint seg0~seg63 are lcd driver outputs for lcd panel segments. seg0 is pin-shared with the spi bus data output line, sdo. seg1 is pin-shared with the spi bus data input line, sdi and the i 2 c bus data line sda. seg2 is pin-shared with the spi bus clock line, sck and the i 2 c bus clock line scl. seg3 is pin-shared with the spi bus select line, scs . seg4 is pin-shared with the peripheral clock line, pclk. seg5 is pin-shared with the peripheral interrupt line, pint . the seg0~seg23 lines can be can be chosen to be either segment driv - ers or cmos outputs using control bits in the lcd control registers. com0~com7 o  com0~com7 are the lcd common outputs. note: the pin description tables represents the largest package type available, therefore some of the pins and func - tions may not be available on smaller package types. absolute maximum ratings supply voltage ...........................v ss  0.3v to v ss +6.0v storage temperature ............................ 50 cto125 c input voltage..............................v ss  0.3v to v dd +0.3v operating temperature........................... 40 cto85 c i ol total ................................................................80ma i oh total.............................................................. 80ma total power dissipation .....................................500mw note: these are stress ratings only. stresses exceeding the range specified under  absolute maximum ratings  may cause substantial damage to the device. functional operation of this device at other conditions beyond those listed in the specification is not implied and prolonged exposure to extreme conditions may affect device reliability. ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 6 may 21, 2012
d.c. characteristics ht56r67 ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions v dd operating voltage  f sys =4mhz 2.2  5.5 v f sys =8mhz 3.0  5.5 v f sys =12mhz 4.5  5.5 v av dd analog operating voltage  v ref =av dd 3.0  5.0 v i dd1 operating current (crystal osc, rc osc) 3v no load, f sys =f m =1mhz  170 250 a 5v  380 570 a i dd2 operating current (crystal osc, rc osc) 3v no load, f sys =f m =2mhz  240 360 a 5v  490 730 a i dd3 operating current (crystal osc, rc osc) 3v no load, f sys =f m =4mhz (note 5)  440 660 a 5v  900 1350 a i dd4 operating current (ec mode, filter on) 3v no load, f sys =f m =4mhz  380 570 a 5v  720 1080 a i dd5 operating current (ec mode, filter off) 3v no load, f sys =f m =4mhz  370 550 a 5v  680 1020 a i dd6 operating current (crystal osc, rc osc) 5v no load, f sys =f m =8mhz  1.8 2.7 ma i dd7 operating current (crystal osc, rc osc) 5v no load, f sys =f m =12mhz  2.6 4.0 ma i dd8 operating current (slow mode, f m =4mhz) (crystal osc, rc osc) 3v no load, f sys =f slow =500khz  150 220 a 5v  340 510 a i dd9 operating current (slow mode, f m =4mhz) (crystal osc, rc osc) 3v no load, f sys =f slow =1mhz  180 270 a 5v  400 600 a i dd10 operating current (slow mode, f m =4mhz) (crystal osc, rc osc) 3v no load, f sys =f slow =2mhz  270 400 a 5v  560 840 a i dd11 operating current (slow mode, f m =8mhz) (crystal osc, rc osc) 3v no load, f sys =f slow =1mhz  240 360 a 5v  540 810 a i dd12 operating current (slow mode, f m =8mhz) (crystal osc, rc osc) 3v no load, f sys =f slow =2mhz  320 480 a 5v  680 1020 a i dd13 operating current (slow mode, f m =8mhz) (crystal osc, rc osc) 3v no load, f sys =f slow =4mhz  500 750 a 5v  1000 1500 a i stb1 standby current ( sleep) (f sys ,f sub ,f s ,f lcd ,f wdt =off) 3v no load, system halt, wdt off  0.2 1.0 a 5v  0.3 2.0 a i stb2 standby current ( sleep) (f sys ,f lcd ,f wdt =f sub =32768hz (note 1) or 32k_int rc osc) 3v no load, system halt, wdt on  12 a 5v  35 a ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 7 may 21, 2012
symbol parameter test conditions min. typ. max. unit v dd conditions i stb3 standby current ( idle) (f sys ,f wdt =off; f s (note 3)= f sub =32768hz (note 1) or 32k_int rc osc) 3v no load, system halt, wdt off, lcd on (note 2), 1 / 2 bias, c type, v lcd1 =v dd  12 a 5v  35 a i stb4 standby current ( idle) (f sys ,f wdt =off; f s (note 3)= f sub =32768hz (note 1) or 32k_int rc osc) 3v no load, system halt, wdt off, lcd on (note 2), 1 / 3 bias, c type, v lcd1 =3v  12 a 5v  35 a i stb5 standby current ( idle) (f sys ,f wdt =off; f s (note 3)= f sub =32768hz (note 1) or 32k_int rc osc) 3v no load, system halt, wdt off, lcd on (note 2), r type, v lcd1 =v dd , 1 / 2 bias (r bias =400k )  10 15 a 5v  18 27 a i stb6 standby current ( idle) (f sys ,f wdt =off; f s (note 3)= f sub =32768hz (note 1) or 32k_int rc osc) 3v no load, system halt, wdt off, lcd on (note 2), r type, v lcd1 =v dd , 1 / 3 bias (r bias =600k )  10 15 a 5v  16 24 a i stb7 standby current ( idle) (f sys =on, f sys =f m =4mhz, f wdt ,f lcd =off, f s (note 3)=f sub =32768hz (note 1) or 32k_int rc osc) 3v no load, system halt, wdt off, lcd off, spi or i 2 c on, pclk on, pclk=f sys /8  150 250 a 5v  350 550 a v il1 input low voltage for i/o ports, tmr and int  0  0.3v dd v v ih1 input high voltage for i/o ports, tmr and int  0.7v dd  v dd v v il2 input low voltage (res )  0  0.4v dd v v ih2 input high voltage (res )  0.9v dd  v dd v v lvr low voltage reset voltage  configuration option: 2.1v 1.98 2.1 2.22 v  configuration option: 3.15v 2.98 3.15 3.32 v  configuration option: 4.2v 3.98 4.2 4.42 v v lvd low voltage detector voltage  configuration option: 2.2v 2.08 2.2 2.32 v  configuration option: 3.3v 3.12 3.3 3.50 v  configuration option: 4.4v 4.12 4.4 4.70 v i ol1 i/o port sink current 3v v ol =0.1v dd 612  ma 5v 10 25  ma i oh1 i/o port source current 3v v oh =0.9v dd 2 4  ma 5v 5 8  ma i ol2 lcd common and segment current 3v v ol =0.1v dd 210 420  a 5v 350 700  a i oh2 lcd common and segment current 3v v oh =0.9v dd 80 160  a 5v 180 360  a r ph pull-high resistance for i/o ports 3v  20 60 100 k 5v 10 30 50 k ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 8 may 21, 2012
note: 1. 32768hz is in slow start mode (rtcc.4=1) for the d.c. current measurement. 2. lcd waveform is in type a condition. 3. f s is the internal clock for the buzzer, rtc interrupt, time base interrupt and the wdt. 4. both timer/event counters are off. timer filter is disabled for all test conditions. 5. all peripherals are in off condition if not mentioned at i dd ,i stb tests. ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions v dd operating voltage  f sys =4mhz 2.2  5.5 v f sys =8mhz 3.0  5.5 v f sys =12mhz 4.5  5.5 v av dd analog operating voltage  v ref =av dd 3.0  5.0 v i dd1 operating current (crystal osc, rc osc) 3v no load, f sys =f m =1mhz  170 250 a 5v  380 570 a i dd2 operating current (crystal osc, rc osc) 3v no load, f sys =f m =2mhz  240 360 a 5v  490 730 a i dd3 operating current (crystal osc, rc osc) 3v no load, f sys =f m =4mhz (note 5)  440 660 a 5v  900 1350 a i dd4 operating current (ec mode, filter on) 3v no load, f sys =f m =4mhz  380 570 a 5v  720 1080 a i dd5 operating current (ec mode, filter off) 3v no load, f sys =f m =4mhz  370 550 a 5v  680 1020 a i dd6 operating current (crystal osc, rc osc) 5v no load, f sys =f m =8mhz  1.8 2.7 ma i dd7 operating current (crystal osc, rc osc) 5v no load, f sys =f m =12mhz  2.6 4.0 ma i dd8 operating current (slow mode, f m =4mhz) (crystal osc, rc osc) 3v no load, f sys =f slow =500khz  150 220 a 5v  340 510 a i dd9 operating current (slow mode, f m =4mhz) (crystal osc, rc osc) 3v no load, f sys =f slow =1mhz  180 270 a 5v  400 600 a i dd10 operating current (slow mode, f m =4mhz) (crystal osc, rc osc) 3v no load, f sys =f slow =2mhz  270 400 a 5v  560 840 a i dd11 operating current (slow mode, f m =8mhz) (crystal osc, rc osc) 3v no load, f sys =f slow =1mhz  240 360 a 5v  540 810 a i dd12 operating current (slow mode, f m =8mhz) (crystal osc, rc osc) 3v no load, f sys =f slow =2mhz  320 480 a 5v  680 1020 a i dd13 operating current (slow mode, f m =8mhz) (crystal osc, rc osc) 3v no load, f sys =f slow =4mhz  500 750 a 5v  1000 1500 a ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 9 may 21, 2012
symbol parameter test conditions min. typ. max. unit v dd conditions i stb1 standby current ( sleep) (f sys ,f sub ,f s ,f lcd ,f wdt =off) 3v no load, system halt, lcd off, wd off  0.2 1.0 a 5v  0.3 2.0 a i stb2 standby current ( sleep) (f sys ,f lcd ,f wdt =f sub =32768hz (note 1) or 32k rc osc) 3v no load, system halt, lcd off, wd off  12 a 5v  35 a i stb3 standby current ( idle) (f sys ,f wdt =off; f s (note 3)= f sub =32768hz (note 1) or 32k rc osc) 3v no load, system halt, wdt off, lcd on (note 2), 1/5 bias (r bias =1m), v lcd =v dd  610 a 5v  10 15 a i stb4 standby current ( idle) (f sys ,f wdt =off; f s (note 3)= f sub =32768hz (note 1) or 32k rc osc) 3v no load, system halt, wdt off, lcd on (note 2), 1/4 bias (r bias =800k), v lcd =v dd  610 a 5v  10 15 a i stb5 standby current ( idle) (f sys ,f wdt =off; f s (note 3)= f sub =32768hz (note 1) or 32k rc osc) 3v no load, system halt, wdt off, lcd on (note 2), 1/3 bias (r bias =600k), v lcd =v dd  812 a 5v  12 16 a i stb6 standby current ( idle) (f sys ,f wdt =off; f s (note 3)= f sub =32768hz (note 1) or 32k rc osc) 3v no load, system halt, wdt off, lcd on (note 2), 1/5 bias (r bias =100k), v lcd =v dd  26 39 a 5v  44 66 a i stb7 standby current ( idle) (f sys ,f wdt =off; f s (note 3)= f sub =32768hz (note 1) or 32k rc osc) 3v no load, system halt, wdt off, lcd on (note 2), 1/4 bias (r bias =80k), v lcd =v dd  32 48 a 5v  54 81 a i stb8 standby current ( idle) (f sys ,f wdt =off; f s (note 3)= f sub =32768hz (note 1) or 32k rc osc) 3v no load, system halt, wdt off, lcd on (note 2), 1/3 bias (r bias =60k), v lcd =v dd  44 66 a 5v  70 105 a i stb9 standby current ( idle) (f sys on, f sys =f m =4mhz, f wdt ,f lcd off; f s (note 3)= f sub =32768hz (note 1) or 32k rc osc) 3v no load, system halt, lcd off, wdt off, spi or i 2 c on, pclk on, pclk=f sys /8  150 250 a 5v  350 550 a v il1 input low voltage for i/o ports, tmr and int  0  0.3v dd v v ih1 input high voltage for i/o ports, tmr and int  0.7v dd  v dd v v il2 input low voltage (res )  0  0.4v dd v v ih2 input high voltage (res )  0.9v dd  v dd v v lvr low voltage reset voltage  configuration option: 4.2v 3.98 4.2 4.42 v configuration option: 3.15v 2.98 3.15 3.32 v configuration option: 2.1v 1.98 2.1 2.22 v v lvd low voltage detector voltage  configuration option: 2.2v 2.08 2.2 2.32 v configuration option: 3.3v 3.12 3.3 3.50 v configuration option: 4.4v 4.12 4.4 4.70 v ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 10 may 21, 2012
symbol parameter test conditions min. typ. max. unit v dd conditions i ol1 i/o port sink current (pa, pb, pd; seg, com level or led output) 3v v ol =0.1v dd 612  ma 5v 10 25  ma i oh1 i/o port source current (pa, pb, pd; seg, com level or led output) 3v v oh =0.9v dd 2 4  ma 5v 5 8  ma i ol2 lcd common and segment current 3v v ol =0.1v dd 210 420  a 5v 350 700  a i oh2 lcd common and segment current 3v v oh =0.9v dd 80 160  a 5v 180 360  a r ph pull-high resistance for i/o ports 3v  20 60 100 k 5v  10 30 50 k note: 1. 32768hz is slow start mode (rtcc.4=1) in d.c. current measurement. 2. lcd waveform is in type a condition. 3. f s is internal clock for buzzer, rtc, time base and wdt. 4. timer0/1 off. timer filter disable in all test condition. 5. all peripherals are in off condition if not mentioned at i dd ,i stb tests. a.c. characteristics ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions f sys system clock (crystal osc, rc osc)  2.2v~5.5v 100  4000 khz 3.0v~5.5v 100  8000 khz 4.5v~5.5v 100  12000 khz f rtcosc rtc frequency  32768  hz f timer timer i/p frequency (tmr0/tmr1)  2.2v~5.5v 0  4000 khz 3.0v~5.5v 0  8000 khz 4.5v~5.5v 0  12000 khz f rc32k 32k rc oscillator  2.2v~5.5v, after trim 28.8 32.0 35.2 khz t res external reset low pulse width  1   s t lvr low voltage reset time  0.1 0.4 0.6 ms t sst1 system start-up timer period  power-on  1024  t sys * t sst2 system start-up timer period for xtal or rtc oscillator  wake-up from power down mode  1024  t sys * t sst3 system start-up timer period for external rc or external clock  wake-up from power down mode  12 t sys * t int interrupt pulse width  1   s note: *t sys =1/f sys ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 11 may 21, 2012
adc characteristics ht56r67 ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions v ad a/d input voltage  52qfp, 64lqfp 0  av dd v 100lqfp 0  v ref v v ref a/d input reference voltage range  av dd =5v 1.6  av dd +0.1 v dnl a/c differential non-linearity  av dd =5v, v ref =av dd , t ad =0.5s 2  2 lsb inl adc integral non-linearity  av dd =5v, v ref =av dd , t ad =0.5s 4  4 lsb i adc additional power consumption if a/d converter is used 3v   0.50 0.75 ma 5v  1.00 1.50 ma t ad a/d clock period  0.5  s t adc a/d conversion time   16  t ad ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions v ad a/d input voltage  100lqfp 0  av dd v 128qfp 0  v ref v v ref a/d input reference voltage range  av dd =5v 1.6  av dd +0.1 v dnl a/c differential non-linearity  av dd =5v, v ref =av dd , t ad =0.5s 2  2 lsb inl adc integral non-linearity  av dd =5v, v ref =av dd , t ad =0.5s 4  4 lsb i adc additional power consumption if a/d converter is used 3v   0.50 0.75 ma 5v  1.00 1.50 ma t ad a/d clock period  0.5  s t adc a/d conversion time   16  t ad ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 12 may 21, 2012
power-on reset characteristics ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions v por vdd start voltage to ensure power-on reset   100 mv rr vdd vdd raising rate to ensure power-on reset  0.035  v/ms t por minimum time for vdd stays at v por to ensure power-on reset  1  ms ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 13 may 21, 2012 
 . % % .      . % %    
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 14 may 21, 2012 system architecture a key factor in the high-performance features of the holtek range of microcontrollers is attributed to their in - ternal system architecture. the range of devices take advantage of the usual features found within risc microcontrollers providing increased speed of operation and enhanced performance. the pipelining scheme is implemented in such a way that instruction fetching and instruction execution are overlapped, hence instructions are effectively executed in one cycle, with the exception of branch or call instructions. an 8-bit wide alu is used in practically all instruction set operations, which carries out arithmetic operations, logic operations, rotation, in - crement, decrement, branch decisions, etc. the internal data path is simplified by moving data through the accu - mulator and the alu. certain internal registers are im - plemented in the data memory and can be directly or indirectly addressed. the simple addressing methods of these registers along with additional architectural fea - tures ensure that a minimum of external components is required to provide a functional i/o and a/d control sys - tem with maximum reliability and flexibility. this makes the device suitable for low-cost, high-volume production for controller applications. clocking and pipelining the main system clock, derived from either a crys- tal/resonator or rc oscillator is subdivided into four in- ternally generated non-overlapping clocks, t1~t4. the program counter is incremented at the beginning of the t1 clock during which time a new instruction is fetched. the remaining t2~t4 clocks carry out the decoding and execution functions. in this way, one t1~t4 clock cycle forms one instruction cycle. although the fetching and execution of instructions takes place in consecutive in - struction cycles, the pipelining structure of the microcontroller ensures that instructions are effectively executed in one instruction cycle. the exception to this are instructions where the contents of the program counter are changed, such as subroutine calls or jumps, in which case the instruction will take one more instruction cycle to execute. when the rc oscillator is used, osc2 is free for use as a t1 phase clock synchronizing pin. this t1 phase clock has a frequency of f sys /4 with a 1:3 high/low duty cycle. for instructions involving branches, such as jump or call instructions, two machine cycles are required to com - plete instruction execution. an extra cycle is required as the program takes one cycle to first obtain the actual jump or call address and then another cycle to actually execute the branch. the requirement for this extra cycle should be taken into account by programmers in timing sensitive applications. '        <  =  > ! "         <  =   / > '        <  =  ? / > ! "         <  =  > '        <  =  ? , > ! "         <  =  ? / >   ? /  ? ,  
         * =         * >         *   /                     *   ,         *   0         *   1 
 

 system clocking and pipelining '        <  / ! "         <  / '        <  , '      
 
 / , 0 1 2 3 % ! + $ @ a   .  $ b c / , d e $ + +  % ! + $ @  +  c / , d e a a 8   ! "         <  , '        <  0 '        <  3 ! "         <  3 '        <  4 instruction fetching
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 15 may 21, 2012 program counter during program execution, the program counter is used to keep track of the address of the next instruction to be executed. it is automatically incremented by one each time an instruction is executed except for instructions, such as jmp or call that demand a jump to a non-consecutive program memory address. it must be noted that only the lower 8 bits, known as the program counter low register, are directly addressable. when executing instructions requiring jumps to non-consecutive addresses such as a jump instruction, a subroutine call, interrupt or reset, etc., the microcontroller manages program control by loading the required address into the program counter. for condi - tional skip instructions, once the condition has been met, the next instruction, which has already been fetched during the present instruction execution, is dis - carded and a dummy cycle takes its place while the cor - rect instruction is obtained. the lower byte of the program counter, known as the program counter low register or pcl, is available for program control and is a readable and writable register. by transferring data directly into this register, a short pro - gram jump can be executed directly, however, as only this low byte is available for manipulation, the jumps are limited to the present page of memory, that is 256 loca - tions. when such program jumps are executed it should also be noted that a dummy cycle will be inserted. the lower byte of the program counter is fully accessi - ble under program control. manipulating the pcl might cause program branching, so an extra cycle is needed to pre-fetch. further information on the pcl register can be found in the special function register section. mode program counter bits b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 initial reset 000000 0000000000 external interrupt 0 000000 0000000100 external interrupt 1 000000 0000001000 timer/event counter 0 overflow 000000 0000001100 timer/event counter 1 overflow 000000 0000010000 spi/i 2 c interrupt 000000 0000010100 multi-function interrupt 000000 0000011000 skip program counter + 2 loading pcl pc15 pc14 pc13 pc12 pc11 pc10 pc9 pc8 @7 @6 @5 @4 @3 @2 @1 @0 jump, call branch bp.7 bp.6 bp.5 #12 #11 #10 #9 #8 #7 #6 #5 #4 #3 #2 #1 #0 return from subroutine s15 s14 s13 s12 s11 s10 s9 s8 s7 s6 s5 s4 s3 s2 s1 s0 program counter note: pc15~pc8: current program counter bits @7~@0: pcl bits #12~#0: instruction code address bits s15~s0: stack register bits for the ht56r688, the program counter is 16 bits wide, i.e. from b15~b0. for the ht56r67/ht56r678/ht56c678, the program counter is 15 bits wide, i.e. from b14~b0. for the ht56r668/ht56c668, the program counter is 14 bits wide, i.e. from b13~b0, therefore the b12 column in the table is not applicable. bp.7, bp.6, bp.5: bank pointer bits / 0 / ,  4 6              7  < 2          !  " 7  < 3 / 1 7  < 4 / 2
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 16 may 21, 2012 stack this is a special part of the memory which is used to save the contents of the program counter only. the stack has multiple levels depending upon the device and is neither part of the data nor part of the program space, and is neither readable nor writeable. the acti - vated level is indexed by the stack pointer, sp, and is neither readable nor writeable. at a subroutine call or in - terrupt acknowledge signal, the contents of the program counter are pushed onto the stack. at the end of a sub - routine or an interrupt routine, signaled by a return in - struction, ret or reti, the program counter is restored to its previous value from the stack. after a device reset, the stack pointer will point to the top of the stack. if the stack is full and an enabled interrupt takes place, the interrupt request flag will be recorded but the ac- knowledge signal will be inhibited. when the stack pointer is decremented, by ret or reti, the interrupt will be serviced. this feature prevents stack overflow al- lowing the programmer to use the structure more easily. however, when the stack is full, a call subroutine in- struction can still be executed which will result in a stack overflow. precautions should be taken to avoid such cases which might cause unpredictable program branching. arithmetic and logic unit  alu the arithmetic-logic unit or alu is a critical area of the microcontroller that carries out arithmetic and logic oper - ations of the instruction set. connected to the main microcontroller data bus, the alu receives related in - struction codes and performs the required arithmetic or logical operations after which the result will be placed in the specified register. as these alu calculation or oper - ations may result in carry, borrow or other status changes, the status register will be correspondingly up - dated to reflect these changes. the alu supports the following functions:  arithmetic operations: add, addm, adc, adcm, sub, subm, sbc, sbcm, daa  logic operations: and, or, xor, andm, orm, xorm, cpl, cpla  rotation rra, rr, rrca, rrc, rla, rl, rlca, rlc  increment and decrement inca, inc, deca, dec  branch decision, jmp, sz, sza, snz, siz, sdz, siza, sdza, call, ret, reti program memory the program memory is the location where the user code or program is stored. for these device the pro - gram memory is an otp type, which means it can be programmed only one time. by using the appropriate programming tools, this otp memory device offer users the flexibility to conveniently debug and develop their applications while also offering a means of field pro - gramming. structure the program memory has a capacity of 16k  16 bits to 32k 16 bits. the program memory is addressed by the program counter and also contains data, table informa - tion and interrupt entries. table data, which can be setup in any location within the program memory, is ad - dressed by a separate table pointer register. special vectors within the program memory, certain locations are re- served for special usage such as reset and interrupts.  location 000h this vector is reserved for use by the device reset for program initialisation. after a device reset is initiated, the program will jump to this location and begin execution.  location 004h this vector is used by the external interrupt 0. if the external interrupt pin receives an active edge, the pro - gram will jump to this location and begin execution if the external interrupt is enabled and the stack is not full.  location 008h this vector is used by the external interrupt 1. if the external interrupt pin receives an active edge, the pro - gram will jump to this location and begin execution if the external interrupt is enabled and the stack is not full.  location 00ch this internal vector is used by the timer/event coun - ter 0. if a timer/event counter 0 overflow occurs, the program will jump to this location and begin execution if the timer/event counter interrupt is enabled and the stack is not full.                *  +  &    /    *  +  &    ,    *  +  &    0    *  +  &    / ,                f     *    *  
   7       f     *
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 17 may 21, 2012  location 010h this internal vector is used by the timer/event coun - ter 1. if a timer/event counter 1 overflow occurs, the program will jump to this location and begin execution if the timer/event counter interrupt is enabled and the stack is not full.  location 014h this internal vector is used by the spi/i 2 c interrupt. when either an spi or i 2 c bus, dependent upon which one is selected, requires data transfer, the program will jump to this location and begin execution if the spi/i 2 c interrupt is enabled and the stack is not full.  location 018h this internal vector is used by the multi-function inter - rupt. the multi-function interrupt vector is shared by several internal functions such as a time base over - flow, a real time clock overflow, an a/d converter conversion completion, an active edge appearing on the external peripheral interrupt pin, a timer/event counter 2 or a timer/event counter 3 overflow. the program will jump to this location and begin execution if the relevant interrupt is enabled and the stack is not full. look-up table any location within the program memory can be defined as a look-up table where programmers can store fixed data. to use the look-up table, the table pointer must first be setup by placing the lower order address of the look up data to be retrieved in the table pointer register, tblp. this register defines the lower 8-bit address of the look-up table. after setting up the table pointer, the table data can be retrieved from the current program memory page or last program memory page using the  tabrdc[m]  or  tabrdl [m] instructions, respectively. when these in - structions are executed, the lower order table byte from the program memory will be transferred to the user de - fined data memory register [m] as specified in the in- struction. the higher order table data byte from the program memory will be transferred to the tblh special register. any unused bits in this transferred higher order byte will be read as 0. the following diagram illustrates the addressing/data flow of the look-up table: instruction table location bits b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 tabrdc [m] pc15 pc14 pc13 pc12 pc11 pc10 pc9 pc8 @7 @6 @5 @4 @3 @2 @1 @0 tabrdl [m] 1 1 111111@7@6@5@4@3@2@1@0 table location note: pc15~pc8: current program counter bits @7~@0: table pointer tblp bits for the ht56r688, the table address location is 16 bits, i.e. from b15~b0. for the ht56r67/ht56r678/ht56c678, the table address location is 15 bits, i.e. from b14~b0. for the ht56r668/ht56c668, the table address location is 14 bits, i.e. from b13~b0. 6 / 1 d 6 6 6 d 6 6 1 d 6 6  d 6 6 d 6 / 6 d 6 /  d 8           / ' ' ' d / 3  
  

 
  
 .     ! "        8  6         .     
         6         .        #  ,         .     ! "        8  /         .     
         /         .        
g '  
         .     6 / d 4 6 6 d 4 ' ' d  6 6 d ' ' ' d / 6 6 6 d program memory structure                                 d
   7     7 +   7 + d  
f
      c e             d
   7                +  -  7   
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 18 may 21, 2012 table program example the following example shows how the table pointer and table data is defined and retrieved from the ht56r678/ ht56c678. this example uses raw table data located in the last page which is stored there using the org state - ment. the value at this org statement is 7f00h which refers to the start address of the last page within the 32k program memory of the ht56r678/ht56c678 microcontroller. the table pointer is setup here to have an initial value of 06h . this will ensure that the first data read from the data table will be at the program memory address 7f06h or 6 locations after the start of the last page. note that the value for the table pointer is referenced to the first address of the present page if the  tabrdc [m] instruction is being used. the high byte of the table data which in this case is equal to zero will be transferred to the tblh register automatically when the  tabrdl [m] instruction is executed. because the tblh register is a read-only register and cannot be restored, care should be taken to ensure its protection if both the main routine and interrupt service routine use table read instructions. if using the table read instructions, the interrupt service routines may change the value of the tblh and subsequently cause errors if used again by the main routine. as a rule it is recommended that simultaneous use of the table read instructions should be avoided. however, in situations where simultaneous use cannot be avoided, the inter - rupts should be disabled prior to the execution of any main routine table-read instructions. note that all table related instructions require two instruction cycles to complete their operation. tempreg1 db ? ; temporary register #1 tempreg2 db ? ; temporary register #2 : : mov a,06h ; initialise table pointer - note that this address ; is referenced mov tblp,a ; to the last page or present page : : tabrdl tempreg1 ; transfers value in table referenced by table pointer ; to tempregl ; data at prog. memory address 7f06h transferred to ; tempreg1 and tblh dec tblp ; reduce value of table pointer by one tabrdl tempreg2 ; transfers value in table referenced by table pointer ; to tempreg2 ; data at prog.memory address 7f05h transferred to ; tempreg2 and tblh ; in this example the data 1ah is transferred to ; tempreg1 and data 0fh to register tempreg2 ; the value 00h will be transferred to the high byte ; register tblh : : org 7f00h ; sets initial address of last page dc 00ah, 00bh, 00ch, 00dh, 00eh, 00fh, 01ah, 01bh : :
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 19 may 21, 2012 data memory the data memory is a volatile area of 8-bit wide ram internal memory and is the location where temporary in - formation is stored. divided into three sections, the first of these is an area of ram where special function regis - ters are located. these registers have fixed locations and are necessary for correct operation of the device. many of these registers can be read from and written to directly under program control, however, some remain protected from user manipulation. the second area of data memory is reserved for general purpose use. all locations within this area are read and write accessible under program control. the third area is reserved for the lcd memory. this special area of data memory is mapped directly to the lcd display so data written into this memory area will directly affect the displayed data. the addresses of the lcd memory area overlap those in the general purpose data memory area. switching between the different data memory banks is achieved by setting the bank pointer to the correct value. structure the data memory is subdivided into several banks, all of which are implemented in 8-bit wide ram. the data memory located in bank 0 is subdivided into two sec - tions, the special purpose data memory and the gen- eral purpose data memory. the start address of the data memory for all devices is the address 00h . registers which are common to all microcontrollers , such as acc, pcl, etc., have the same data memory address. the lcd memory is mapped into bank 1. banks 2 to 12 contain only general purpose data memory for those devices with larger data memory capacities. as the special purpose data memory registers are mapped into all bank areas, they can subsequently be accessed from any bank location. )             %           
         %          6 6 d 1 6 d ' ' d 0 ' d 7  *  6 7  *  , 7  *  / + %      7  *  0 7  *  / , data memory structure bank number 0123456789101112 ht56r67 - 2304 bytes spdm sa common 00h ea common 3fh gpdm sa 40h 40h 40h 40h 40h 40h 40h 40h 40h 40h 40h 40h 40h ea ffh 70h ffh ffh ffh ffh ffh ffh ffh ffh ffh ffh ffh ht56r668 ht56c668 ht56r678 ht56c678 ht56r688 - 2304 bytes spdm sa common 00h ea common 3fh gpdm sa 40h 40h 40h 40h 40h 40h 40h 40h 40h 40h 40h 40h 40h ea ffh bfh ffh ffh ffh ffh ffh ffh ffh ffh ffh ffh ffh data memory content note: spdm: special purpose data memory gpdm: general purpose data memory sa: start address ea: end address x: not implemented
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 20 may 21, 2012 general purpose data memory all microcontroller programs require an area of read/write memory where temporary data can be stored and retrieved for use later. it is this area of ram memory that is known as general purpose data memory. this area of data memory is fully accessible by the user pro - gram for both read and write operations. by using the  set [m].i and  clr [m].i instructions individual bits can be set or reset under program control giving the user a large range of flexibility for bit manipulation in the data memory. for devices with larger data memory ca - pacities, the general purpose data memory, in addition to being located in bank 0, is also stored in banks 2 to 12, the actual number of banks present depends upon the device selected. special purpose data memory this area of data memory is where registers, necessary for the correct operation of the microcontroller , are stored. most of the registers are both read and write type but some are protected and are read only, the details of which are located under the relevant special function register section. note that for locations that are unused, any read instruction to these addresses will return the unknow value. the special function registers are mapped into all banks and can therefore be accessed from any bank location. display memory the data to be displayed on the lcd or led display is stored in an area of fully accessible data memory. by writing to this area of ram, the display output can be di- rectly controlled by the application program. as this memory exists in bank 1, but have addresses which map into the general purpose data memory, it is neces - sary to first ensure that the bank pointer is set to the value 01h before accessing the display memory. the display memory can only be accessed indirectly using the memory pointer mp1 and the indirect addressing register iar1. when the bank pointer is set to bank 1 to access the display memory, if any addresses with a value less than 40h are read, the special purpose memory in bank 0 will be accessed. also, if the bank pointer is set to bank 1, if any addresses higher than the last address in bank 1 are read, then a value of 00h will be returned. special function registers to ensure successful operation of the microcontroller , certain internal registers are implemented in the data memory area. these registers ensure correct operation of internal functions such as timers, interrupts, etc., as well as external functions such as i/o data control and a/d converter operation. the location of these registers within the data memory begins at the address 00h. any unused data memory locations between these spe - cial function registers and the point where the general purpose memory begins is reserved for future expan - sion purposes, attempting to read data from these loca - tions will return a unknow value. 6 6 d 6 / d 6 , d 6 0 d 6 1 d 6 2 d 6 3 d 6 4 d 6  d 6 5 d 6 $ d 6 7 d 6 d 6 % d 6 ! d 6 ' d / 6 d / / d / , d / 0 d / 1 d / 2 d / 3 d / 4 d /  d / 5 d / $ d / 7 d / d / % d / ! d / ' d , 6 d , / d , , d , 0 d , 1 d , 2 d , 3 d , 4 d ,  d , 5 d , $ d , 7 d , d , % d , ! d , ' d 0 6 d 0 / d 0 , d 0 0 d 0 1 d 0 2 d 0 3 d 0 4 d 0  d 0 5 d 0 $ d 0 7 d 0 d 0 % d 0 ! d 0 ' d        a                h 6 6 h   $  6   6  $  /   / 7  $  +  7 +   7 + d     $     8  6    6    6    / d    / +    /  $  $  7  7    %  %    6 +    6 d    / +    / d  8  /    , +    , d    0 +    0 d $ %  + $ %  d $ %  $   + ;   %  $    $    7       %    8  ! % ) ! + %   + + %    / + %    ,     '  6  '  /     + 6     + /    %     $  #     + ,    ,    ,    0    0         #                 #                  $  6   6  $  /   / 7  $  +  7 +   7 + d     $     8  6    6    6    / d    / +    /  $  $  7  7  %  %    6 +    6 d    / +    / d  8  /    , +    , d    0 +    0 d $ %  + $ %  d $ %  $   + ;   %  $    $    7    %    8  ! % ) ! + ! %   + + %   + + %    / + %    ,     '  6  '  /     + 6     + /    %     $  #     + ,    ,    ,    0    0 special purpose data memory
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 21 may 21, 2012 indirect addressing registers  iar0, iar1 the indirect addressing registers, iar0 and iar1, al - though having their locations in normal ram register space, do not actually physically exist as normal regis - ters. the method of indirect addressing for ram data manipulation uses these indirect addressing registers and memory pointers, in contrast to direct memory ad - dressing, where the actual memory address is speci - fied. actions on the iar0 and iar1 registers will result in no actual read or write operation to these registers but rather to the memory location specified by their corre - sponding memory pointers, mp0 or mp1. acting as a pair, iar0 and mp0 can together access data from bank 0 while the iar1 and mp1 register pair can access data from any bank. as the indirect addressing registers are not physically implemented, reading the indirect ad - dressing registers indirectly will return a result of 00h and writing to the registers indirectly will result in no op - eration. memory pointers  mp0, mp1 two memory pointers, known as mp0 and mp1 are pro - vided. these memory pointers are physically imple - mented in the data memory and can be manipulated in the same way as normal registers providing a conve - nient way with which to address and track data. when any operation to the relevant indirect addressing regis - ters is carried out, the actual address that the microcontroller is directed to, is the address specified by the related memory pointer. mp0, together with indirect addressing register, iar0, are used to access data from bank 0, while mp1 and iar1 are used to access data from all banks. the following example shows how to clear a section of four ram locations already defined as locations adres1 to adres4. data .section
data
adres1 db ? adres2 db ? adres3 db ? adres4 db ? block db ? code .section at 0
code
org 00h start: mov a,04h ; setup size of block mov block,a mov a,offset adres1 ; accumulator loaded with first ram address mov mp0,a ; setup memory pointer with first ram address loop: clr iar0 ; clear the data at address defined by mp0 inc mp0 ; increment memory pointer sdz block ; check if last memory location has been cleared jmp loop continue: the important point to note here is that in the example shown above, no reference is made to specific ram addresses.
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 22 may 21, 2012 bank pointer  bp the data memory is divided several banks, the total number of which depends upon the device chosen. se - lecting the required data memory area is achieved us - ing the bank pointer. if data in bank 0 is to be accessed, then the bp register must be loaded with the value 00h, while if data in bank 1 is to be accessed, then the bp register must be loaded with the value 01h, and so on. the data memory is initialised to bank 0 after a reset, except for the wdt time-out reset in the power down mode, in which case, the data memory bank remains unaffected. it should be noted that the special function data memory is not affected by the bank selection, which means that the special function registers can be accessed from within any bank. directly addressing the data memory will always result in bank 0 being ac - cessed irrespective of the value of the bank pointer. ac - cessing data from banks other than bank 0 must be implemented using indirect addressing. accumulator  acc the accumulator is central to the operation of any microcontroller and is closely related with operations carried out by the alu. the accumulator is the place where all intermediate results from the alu are stored. without the accumulator it would be necessary to write the result of each calculation or logical operation such as addition, subtraction, shift, etc., to the data memory resulting in higher programming and timing overheads. data transfer operations usually involve the temporary storage function of the accumulator; for example, when transferring data between one user defined register and another, it is necessary to do this by passing the data through the accumulator as no direct transfer between two registers is permitted. program counter low register  pcl to provide additional program control functions, the low byte of the program counter is made accessible to pro - grammers by locating it within the special purpose area of the data memory. by manipulating this register, direct jumps to other program locations are easily imple - mented. loading a value directly into this pcl register will cause a jump to the specified program memory lo - cation, however, as the register is only 8-bit wide, only jumps within the current program memory page are per - mitted. when such operations are used, note that a dummy cycle will be inserted. look-up table registers  tblp, tblh these two special function registers are used to control operation of the look-up table which is stored in the pro - gram memory. tblp is the table pointer and indicates the location where the table data is located. its value must be setup before any table read commands are ex - ecuted. its value can be changed, for example using the inc or dec instructions, allowing for easy table data pointing and reading. tblh is the location where the high order byte of the table data is stored after a table read data instruction has been executed. note that the lower order table data byte is transferred to a user de - fined location. status register  status this 8-bit register contains the zero flag (z), carry flag (c), auxiliary carry flag (ac), overflow flag (ov), power down flag (pdf), and watchdog time-out flag (to). these arithmetic/logical operation and system manage - ment flags are used to record the status and operation of the microcontroller . with the exception of the to and pdf flags, bits in the status register can be altered by instructions like most other registers. any data written into the status register will not change the to or pdf flag. in addition, opera- tions related to the status register may give different re- sults due to the different instruction operations. the to flag can be affected only by a system power-up, a wdt time-out or by executing the  clr wdt or  halt in- struction. the pdf flag is affected only by executing the  halt or  clr wdt instruction or during a system power-up. the z, ov, ac and c flags generally reflect the status of the latest operations.  c is set if an operation results in a carry during an ad - dition operation or if a borrow does not take place dur - ing a subtraction operation; otherwise c is cleared. c is also affected by a rotate through carry instruction.     $     4  6 7  6      &    f    f          b  - 
   h 6 h     < 7  /7  ,7  0 7  27  3 7  0 i 7  6                         %          6 6 6 6 6 6 6 / 6 6 / 6 i / / 6 6 / / 6 / i / / / / 7  *  6   f                  7  *  /  = + %      > 7  *  ,  i  / ,                  %            
                  ;      "  3      
  
 7  4 bank pointer
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 23 may 21, 2012  ac is set if an operation results in a carry out of the low nibbles in addition, or no borrow from the high nib - ble into the low nibble in subtraction; otherwise ac is cleared.  z is set if the result of an arithmetic or logical operation is zero; otherwise z is cleared.  ov is set if an operation results in a carry into the high - est-order bit but not a carry out of the highest-order bit, or vice versa; otherwise ov is cleared.  pdf is cleared by a system power-up or executing the  clr wdt instruction. pdf is set by executing the halt instruction.  to is cleared by a system power-up or executing the  clr wdt or halt instruction. to is set by a wdt time-out. in addition, on entering an interrupt sequence or execut- ing a subroutine call, the status register will not be pushed onto the stack automatically. if the contents of the status registers are important and if the subroutine can corrupt the status register, precautions must be taken to correctly save it. interrupt control registers these 8-bit registers, intc0, intc1, mfic, mfic0, mfic1 and intedge, control the operation of the device interrupt functions. by setting various bits within these registers using standard bit manipulation instructions, the enable/disable function of each interrupt can be inde - pendently controlled. a master interrupt bit within the intc0 register, the emi bit, acts like a global enable/dis - able and is used to set all of the interrupt enable bits on or off. this bit is cleared when an interrupt routine is entered to disable further interrupt and is set by executing the  reti instruction. the intedge register is used to se - lect the active edges for the two external interrupt pins int0 and int1. timer/event counter registers the devices contain several internal 8-bit and 16-bit timer/event counters, the actual amount depends upon which device is selected. the registers tmr0, tmr1, tmr2, tmr3 and the register pair tmr1l/tmr1h are the locations where the timer values are located. these registers can also be preloaded with fixed data to allow different time intervals to be setup. the associated control registers, tmr0c, tmr1c, tmr2c and tmr3c contain the setup information for these timers, which determines in what mode the timer is to be used as well as containing the timer on/off control function. input/output ports and control registers within the area of special function registers, the i/o registers and their associated control registers play a prominent role. all i/o ports have a designated register correspondingly labeled as pa, pb, pc and pd. these labeled i/o registers are mapped to specific addresses within the data memory as shown in the data memory table, which are used to transfer the appropriate output or input data on that port. with each i/o port there is an associated control register labeled pac, pbc, pcc and pdc, also mapped to specific addresses with the data memory. the control register specifies which pins of that port are set as inputs and which are set as outputs. to setup a pin as an input, the corresponding bit of the con- trol register must be set high, for an output it must be set low. during program initialization, it is important to first setup the control registers to specify which pins are out - puts and which are inputs before reading data from or writing data to the i/o ports. one flexible feature of these registers is the ability to directly program single bits us - ing the  set [m].i and  clr [m].i instructions. the ability to change i/o pins from output to input and vice versa by manipulating specific bits of the i/o control reg - isters during normal program operation is a useful fea - ture of these devices. pulse width modulator registers the devices contain multiple pulse width modulator out - puts each with their own related independent control reg - ister pair, known as pwm0l/pwm0h, pwm1l/pwm1h, pwm2l/pwm2h and pwm3l/pwm3h. the 12-bit con - tents of each register pair, which defines the duty cycle value for the modulation cycle of the pulse width modula - tor, along with an enable bit are contained in these regis - ter pairs.    % '  . 9 $ %    & %    $       '    ( #    ( ) *       +   $      f    $  "

         f    9     f     &   f   -  f    % , $    -          +   $   -      -  f            
      f    8   
      b          h 6 h  4  6 status register
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 24 may 21, 2012 a/d converter registers  adrl, adrh, adcr, acsr the device contains a multiple channel 12-bit a/d con - verter. the correct operation of the a/d requires the use of two data registers and two control registers. the two data registers, a high byte data register known as adrh, and a low byte data register known as adrl, are the register locations where the digital value is placed after the completion of an analog to digital conversion cycle. functions such as the a/d enable/disable, a/d channel selection and a/d clock frequency are deter - mined using the two control registers, adcr and acsr. serial interface registers the device contains two serial interfaces, an spi and an i 2 c interface. the simctl0, simctl1, simctl2 and simar are the control registers for the serial interface function while the simdr is the data register for the se - rial interface data. port a wake-up register  pawu all pins on port a have a wake-up function enable a low going edge on these pins to wake-up the device when it is in a power down mode. the pins on port a that are used to have a wake-up function are selected using this resister. pull-high resistors  papu, pbpu, pcpu, pdpu all i/o pins on ports pa, pb, pc and pd, if setup as in- puts, can be connected to an internal pull-high resistor. the pins which require a pull-high resistor to be con- nected are selected using these registers. register  clkmod the device operates using a dual clock system whose mode is controlled using this register. the register con - trols functions such as the clock source, the idle mode enable and the division ratio for the slow clock. lcd/led registers  lcdctrl, ledctrl, lcdout1, lcdout2 the device contains a fully integrated lcd/led driver function which can be setup in various configurations al - lowing it to control a wide range of external lcd and led panels. most of these options are controlled using the lcdctrl and lectrl registers. as some of the lcd segment driving pins can also be setup to be used as cmos outputs, two registers, lcdout1 and lcdout2, are used to select the required function. miscellaneous register  misc the miscellaneous register is used to control two func - tions. the four lower bits are used for the watchdog timer control, while the highest four bits are used to se - lect open drain outputs for pins pa0~pa3. input/output ports holtek microcontrollers offer considerable flexibility on their i/o ports. with the input or output designation of ev - ery pin fully under user program control, pull-high selec - tions for all ports and wake-up selections on certain pins, the user is provided with an i/o structure to meet the needs of a wide range of application possibilities. the device provides 32 bidirectional input/output lines labeled with port names pa, pb, pc and pd. these i/o ports are mapped to the ram data memory with spe - cific addresses as shown in the special purpose data memory table. all of these i/o ports can be used for in - put and output operations. for input operation, these ports are non-latching, which means the inputs must be ready at the t2 rising edge of instruction  mov a,[m], where m denotes the port address. for output opera - tion, all the data is latched and remains unchanged until the output latch is rewritten. pull-high resistors many product applications require pull-high resistors for their switch inputs usually requiring the use of an exter - nal resistor. to eliminate the need for these external re - sistors, all i/o pins, when configured as an input have the capability of being connected to an internal pull-high resistor. these pull-high resistors are selected using registers papu, pbpu, pcpu and pdpu and are im- plemented using weak pmos transistors. port a wake-up the halt instruction forces the microcontroller into a power down condition which preserves power, a fea- ture that is important for battery and other low-power ap- plications. various methods exist to wake-up the microcontroller , one of which is to change the logic condition on one of the port a pins from high to low. after a halt instruction forces the microcontroller into enter - ing a power down condition, the processor will remain in a low-power state until the logic condition of the se - lected wake-up pin on port a changes from high to low. this function is especially suitable for applications that can be woken up via external switches. each pin on port a can be selected individually to have this wake-up fea - ture using the pawu register. port a open drain function all i/o pins in the device have cmos structures, how - ever port a pins pa0~pa3 can also be setup as open drain structures. this is implemented using the ode0~ ode3 bits in the misc register.
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 25 may 21, 2012 - . %     $     4  %  ! 8 6  6  %  ! 8 /         
   !                
        -      $ 6     %  
      / a       6 a  
      $ /     %  
      / a       6 a  
      $ ,     %  
      / a       6 a  
      $ 0     %  
      / a       6 a  
      % ! 6  %  ! 8 ,  %  ! 8 0  % ! /  % ! ,  % ! 0 pa0~pa3 open drain control  misc . % %   :   *                  *         %       
    % j ;  % j ;        7
 %     7    
           
    
                   
     
   %       
    %     7
  #  
j j  $        *            d
   
 generic input/output structure . % %   :      %       
          7
 %     7    
           
    
                   
     
   %       
    %     7
 $ # %          $  , i $  6    $ # %   &        ,   /   6    *       $               % j ;  j % j ;  j      d
    
         a/d input/output structure
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 26 may 21, 2012 i/o port control registers each i/o port has its own control register known as pac, pbc and pdc, to control the input/output configuration. with this control register, each cmos output or input with or without pull-high resistor structures can be re - configured dynamically under software control. each pin of the i/o ports is directly mapped to a bit in its associ - ated port control register. for the i/o pin to function as an input, the corresponding bit of the control register must be written as a 1 . this will then allow the logic state of the input pin to be directly read by instructions. when the corresponding bit of the control register is written as a 0 , the i/o pin will be setup as a cmos out- put. if the pin is currently setup as an output, instructions can still be used to read the output register. however, it should be noted that the program will in fact only read the status of the output data latch and not the actual logic status of the output pin. pin-shared functions the flexibility of the microcontroller range is greatly en- hanced by the use of pins that have more than one func - tion. limited numbers of pins can force serious design constraints on designers but by supplying pins with multi-functions, many of these difficulties can be over - come. for some pins, the chosen function of the multi-function i/o pins is set by configuration options while for others the function is set by application pro - gram control.  external interrupt inputs the external interrupt pins int0, int1 are pin-shared with the i/o pins pd4, pd5. for applications not re - quiring an external interrupt input, the pin-shared ex - ternal interrupt pin can be used as a normal i/o pin, however to do this, the external interrupt enable bits in the intc0 register must be disabled.  external timer clock input the external timer pins tmr0, tmr1, tmr2 and tmr3 are pin-shared with i/o pins. to configure them to operate as timer inputs, the corresponding control bits in the timer control register must be correctly set and the pin must also be setup as an input. note that the original i/o function will remain even if the pin is setup to be used as an external timer input.  pfd output the device contains a pfd function whose single out - put is pin-shared with i/o pin pa3. the output function of this pin is chosen via a configuration option and re - mains fixed after the device is programmed. note that the corresponding bit of the port control register, pac.3, must setup the pin as an output to enable the pfd output. if the pac port control register has setup the pin as an input, then the pin will function as a nor - mal logic input with the usual pull-high selection, even if the pfd configuration option has been selected.  pwm outputs the device contains several pwm outputs shared with pins pd0~pd3. the pwm output functions are chosen via registers. note that the corresponding bit of the port control register, pdc, must setup the pin as an output to enable the pwm output. if the pdc port control register has setup the pin as an input, then the pin will function as a normal logic input with the usual pull-high selection, even if the pwm registers have enabled the pwm function.  a/d inputs the device contains a multi-channel a/d converter in- puts. all of these analog inputs are pin-shared with i/o pins on port b. if these pins are to be used as a/d in - puts and not as normal i/o pins then the corresponding bits in the a/d converter control register, adcr, must be properly set. there are no configuration options as - sociated with the a/d function. if used as i/o pins, then full pull-high resistor register remain, however if used as a/d inputs then any pull-high resistor selections as - sociated with these pins will be automatically discon - nected. i/o pin structures the accompanying diagrams illustrate the internal structures of some i/o pin types. as the exact logical construction of the i/o pin will differ from these draw - ings, they are supplied as a guide only to assist with the functional understanding of the i/o pins. the wide range of pin-shared structures does not permit all types to be shown.  & /  & /  & / 0 &    $     $ < 6 b   7 < 6 b   < 6 b   % < 6       
  / a       6 a  
      $ < / b   7 < / b   < / b   % < /       
  / a       6 a  
      $ < 4 b   7 < 4 b   < 4 b   % < 4       
  / a       6 a  
      4  "   6  6  "   /  "   4 pull-high resistor register  papu, pbpu, pcpu, pdpu
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 27 may 21, 2012 programming considerations within the user program, one of the first things to con - sider is port initialisation. after a reset, all of the i/o data and port control registers will be set high. this means that all i/o pins will default to an input state, the level of which depends on the other connected circuitry and whether pull-high selections have been chosen. if the port control registers, pac, pbc, pcc and pdc, are then programmed to setup some pins as outputs, these output pins will have an initial high output value unless the associated port data registers, pa, pb, pc and pd, are first programmed. selecting which pins are inputs and which are outputs can be achieved byte-wide by loading the correct values into the appropriate port con - trol register or by programming individual bits in the port control register using the  set [m].i and  clr [m].i in - structions. note that when using these bit control in - structions, a read-modify-write operation takes place. the microcontroller must first read in the data on the en - tire port, modify it to the required new bit values and then rewrite this data back to the output ports. port a has the additional capability of providing wake-up functions. when the device is in the power down mode, various methods are available to wake the device up. one of these is a high to low transition of any of the port a pins. single or multiple pins on port a can be setup to have this function. lcd and led driver for large volume applications, which incorporate an lcd in their design, the use of a custom display rather than a more expensive character based display reduces costs significantly. however, the corresponding com and seg signals required, which vary in both amplitude and time, to drive such a custom display require many special considerations for proper lcd operation to oc - cur. these devices all contain an lcd driver function, which with their internal lcd signal generating circuitry and various options, will automatically generate these time and amplitude varying signals to provide a means of direct driving and easy interfacing to a range of cus - tom lcds. additionally some of the devices also include led driver circuitry which can generated the required signals to drive the com and segment signals for led panels. all device include a wide range of options to enable lcd and led displays of various types to be driven. the ta - ble shows the range of options available across the de - vice range. part no. duty driver no. bias bias type wave type ht56r67 1 / 2 492 1 / 2 or 1 / 3 c or r a or b 1 / 3 493 1 / 4 484 ht56r668 ht56c668 ht56r678 ht56c678 ht56r688 1 / 8 728 1 / 3 or 1 / 4 or 1 / 5 r a or b 1 / 16 6416 lcd selections note: the ht56r67 devices do not have an led driver function. device led duty led driver no. ht56r668 ht56c668 ht56r678 ht56c678 ht56r688 static 721 1 / 4 724 1 / 8 728 1 / 12 6412 1 / 16 6416 led selections note: the and ht56r67 devices do not have an led driver function.  /  ,  0  1  /  ,  0  1  
               f                *      %    read/write timing
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 28 may 21, 2012   , *   #    $   , *   # 1   $ . + % /   . + % / . $ . 7 + %   -        .  = k . + % /  , # 0 > = k . + % /  / # 0 > = k . + % / > + %   #  f f   . $ . 7 + %   -        = k . + % /  / # , > = k . + % / > + %   #  f f .  $ : .  $ : r type bias voltage levels  ht56r67   , *   # 1   $  1  '       * . + % / 6 < /  ' 6 < /  ' 6 < /  ' + %   -               / , . / . + % , . $ . 7 . = k . + % /  / < 2 > = k . + % / > = k . + % /   < 2 .       f    / # 0  7
      > .  $ :   , *   #    $    '       * 6 < /  '        / 6 < /  ' 6 < /  ' , . / . + % , . + % / . $ . 7 = k . + % / > = k . + % /  6 < 2 > .  $ : + %   -        c type bias voltage levels   , *   # 1   $   . + % . $ . 7 + %   -        .  = k . + %  , # 0 > = k . + %  / # 0 > = k . + % > + %   #  f f   , *   #    $   , *   #    $   . + % . $ . 7 + %   -        .  = k . + %  1 # 2 > = k . + %  0 # 2 > = k . + % > + %   #  f f   . + % . $ . 7 + %   -        . % = k . + %  0 # 1 > = k . + %  / # 1 > = k . + % > + %   #  f f  . = k . + %  , # 1 >  . % . !  = k . + %  , # 2 > = k . + %  / # 2 >  r type bias voltage levels  ht56r668/ht56c668/ht56r678/ht56c678/ht56r688
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 29 may 21, 2012 display memory an area of data memory is especially reserved for use for the lcd/led display data. this data area is known as the display memory. any data written here will be au - tomatically read by the internal display driver circuits, which will in turn automatically generate the necessary lcd or led driving signals. therefore any data written into this memory will be immediately reflected into the actual display connected to the microcontroller . as the display memory addresses overlap those of the general purpose data memory, it s stored in its own in - dependent bank 1 area. the data memory bank to be used is chosen by using the bank pointer, which is a special function register in the data memory, with the name, bp. to access the display memory therefore re - quires first that bank 1 is selected by writing a value of 01h to the bp register. after this, the memory can then be accessed by using indirect addressing through the use of memory pointer mp1. with bank 1 selected, then using mp1 to read or write to the memory area, starting with address 40h, will result in operations to the display memory. directly addressing the display memory is not applicable and will result in a data access to the bank 0 general purpose data memory. the accompanying display memory map diagrams shows how the internal display memory is mapped to the segments and commons of the display for the larg- est device, which is the ht56r678/ht56c678/ ht56r688. display memory maps for devices with smaller memory capacities can be extrapolated from these diagrams. the accompanying waveform diagrams show the gen - erated waveforms for a range of duty and bias types. the huge number of permutations of available for the lcd and led waveform types does not permit all types to be depicted. 1 6 d  4 d  4  3  2  1  0  ,  /  6    6    /    , 1 / d  3 d    4   3   2    1    0  ! )  6  ! )  4 /  ! )  /  ! )  4 6 ht56r678/ht56c678/ht56r688 memory map  728 1 6 d 4 ' d  4  3  2  1  0  ,  /  6    6    /    , 1 / d  4  3  2  1  0  ,  /  6  ! )  6  ! )  3 0        5    / 6    / /  ! )  /  ! )  3 , 4 ! d    4   3   2    1    0    / ,    / 0    / 1    / 2  ! )  6  ! )  3 0  ! )  /  ! )  3 ,  6 d  / d 7 ' d 7 ! d ht56r678/ht56c678/ht56r688 memory map  6416
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 30 may 21, 2012 lcd/led registers control registers in the data memory, are used to con - trol the various setup features of the lcd/led driver. there is one control register for the lcd function, lcdctrl, and one for the led function, ledctrl. various bits in these registers control functions such as duty type, bias type, bias resistor selection as well as overall lcd enable and disable. the ledsel bit in the ledctrl register must be first setup to determine whether the display is an led or lcd type. pro - gramming this bit will determine what other options are available. the lcden bit in the lcdctrl and leden bit in the ledctrl register, which provide the overall lcd/led enable/disable function, will only be effective when the device is in the normal, slow or idle mode. if the device is in the sleep mode then the display will al - ways be disabled. bits rsel0 and rsel1 in the lcdctrl register select the internal bias resistors to supply the lcd panel with the correct bias voltages. a choice to best match the lcd panel used in the applica - tion can be selected also to minimise bias current. the type bit in the same register is used to select whether type a or type b lcd control signals are used. two registers, lcdout1 and lcdout2 are used to determine if the output function of display pins seg0~ seg23 are used as segment drivers or cmos outputs. if used as cmos outputs then the display memory is used to determine the logic level of the cmos output pins. note that as only two bits are used to determine the output function of the seg0~seg7 and seg8~seg15 pins, individual pins from these two groups of pins cannot be chosen to have either a seg- ment or cmos output function. the output function of pins seg16~seg23 can be chosen individually to be either a segment driver or a cmos input. lcd reset function the lcd has an internal reset function that is an or function of the inverted lcden bit in the lcdctrl reg - ister and the sleep function. the lcd reset signal is ac - tive high. the lcden signal is the inverse of the lcden bit in the lcdctrl register. reset lcd = sleep mode or lcden . lcden =0 and lcden =1 must be enabled to activate the lcdctrl register function. lcden sleep mode reset lcd 0 off 0on 1 off x 1on lcd reset function clock source the lcd clock source is the internal clock signal, f sub , divided by 8, using an internal divider circuit. the f sub in - ternal clock is supplied by either the internal 32k_int oscillator or the external 32768hz oscillator, the choice of which is determined by a configuration option. for proper lcd operation, this arrangement is provided to generate an ideal lcd clock source frequency of 4khz. f sub clock source lcd clock frequency internal 32k_int osc. 4khz external 32768hz osc. 4khz lcd clock source lcd driver output when the ledsel bit in the ledctrl register is cleared to zero, the com and seg lines will be setup as lcd driver pins to drive the lcd display. only ht56r668/ht56c668/ht56r678/ht56c678/ ht56r688 are with ledctrl register. the number of com and seg outputs supplied by the lcd driver, as well as its biasing and duty selections, are dependent upon how the lcd control bits are pro - grammed. the bias type, whether c or r type is se - lected using a configuration option. only ht56r67 are with r or c type selection configuration option. if the c-type of bias is used when an internal charge pump will be enabled. note that the c-type bias is not available on the 52-pin qfp package type. the nature of liquid crystal displays require that only ac voltages can be applied to their pixels as the applica- tion of dc voltages to lcd pixels may cause permanent damage. for this reason the relative contrast of an lcd display is controlled by the actual rms voltage applied to each pixel, which is equal to the rms value of the voltage on the com pin minus the voltage applied to the seg pin. this differential rms voltage must be greater than the lcd saturation voltage for the pixel to be on and less than the threshold voltage for the pixel to be off. the requirement to limit the dc voltage to zero and to control as many pixels as possible with a minimum num - ber of connections, requires that both a time and ampli - tude signal is generated and applied to the application lcd. these time and amplitude varying signals are au - tomatically generated by the lcd driver circuits in the microcontroller . what is known as the duty determines the number of common lines used, which are also known as backplanes or coms. the duty, which is cho - sen by a control bit to have a value of 1 / 2, 1 / 3, 1 / 4 etc and which equates to a com number of 2, 3, 4 etc, therefore defines the number of time divisions within each lcd signal frame. two types of signal generation are also provided, known as type a and type b, the re - quired type is selected via the type bit in the lcdctrl register. type b offers lower frequency sig - nals, however lower frequencies may introduce flicker - ing and influence display clarity.
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 31 may 21, 2012 + %       # 
           / a       6 a  
           8     b     -             + %  -
       #  f f     
     h + % ! 8 h k / # 6                    + % 
    -      f f + %  
     
              ! + /      ! + 6       / # 0  7
        / # ,  7
  + %  7
  / a  / # 0  7
  6 a  / # ,  7
  8   
      b          h 6 h + %  %      %  @ /     %  @ 6 + %      $     7 / a      7 6 a      $   0        $     4 7  $   @  !  6   ! + /   ! + 6 + % ! 8 %  @ / 3 6 6 *  0 6 6 *  / 6 6 *  2 6 *  6 6 / / 6 / 6 / %  @ 6 / # ,      / # 0      / # 1           &   6 6 / / 6 / 6 / 1 6 6 *  , 6 6 *  3 4 *  0 1 *  lcd control register  lcdctrl - ht56r67   0        $     4 7  $  6 7  $  /  @  ! + %       # 
           a    f      &      h 6 h / a       6 a  
       8     b     - b          + %  -
       #  f f     
     h + % ! 8 h k / # 6            + % 
    -      f f  6   ! + /   ! + 6 + % ! 8 %  @ + %  
     
              ! + /      ! + 6 %  f
  + %  
     7  $  /    7  $  6 6 6 / / 6 6 a  / # 0  7
  6 / a  / # 1  7
  / 6 a  / # 2  7
  / / a       &   6 / 6 / 7
  6 / / " 6 / %  f
  + %       6 a  / #       / a  / # / 3      + %      $     7 6 a      $ / a      7 8   
      b          h 6 h / # 2  7
  / 6 6 6 *  / 6 6 *  2 *  / # 1  7
   6 6 *   6 *  1 *  / # 0  7
  3 6 6 *  3 6 *  0 *  lcd control register  lcdctrl - ht56r668/ht56c668/ht56r678/ht56c678/ht56r688
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 32 may 21, 2012   0 ) &      $     6 + %   + %  6  4  ! ) 6 i  ! ) 4                    / a           6 a   ! )        ! )  i  ! ) / 2                    / a           6 a   ! )       8   
      b          h 6 h lcd output control register  lcdout1   0 ) &      $     ! ) / 3 i  ! ) , 0                    / a           6 a   ! )        6 + %  / 3  4 + %  / 4 + %  /  + %  / 5 + %  , 6 + %  , / + %  , , + %  , 0 lcd output control register  lcdout2  2 0        $     4       + %     + ! % 6 a  + % / a  + ! %  6 + ! %  ! + %  @ ! 6 + ! %       # 
           a    f      &      h 6 h 6 a  
     / a         8     b     - b          + ! %  -
       #  f f     
     h + ! % ! 8 h k / # 6            + ! % 
    -      f f %  f
  + ! %         %  @ ! ,    %  @ ! /    %  @ ! 6 6 6 6 6 / / / /    
/ # 1      / #       / #       / # / ,      / # / ,      / # / 3      / # / 3      6 6 / / 6 6 / / 8   
      b          h 6 h + ! % ! 8     ! )  %  @ ! / %  @ ! ,             
  6 a    -   
&  / a  
    
&         ! )     
  6 a    -   
&  / a  
    
&  6 / 6 / 6 / 6 / led control register  ledctrl - ht56r668/ht56c668/ht56r678/ht56c678/ht56r688
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 33 may 21, 2012 led driver output the led driver uses the com and seg lines to drive the led display. the number of com and seg outputs supplied by the led driver, as well as its biasing and duty selections, are dependent upon how the led con - trol bits are programmed. when the ledsel bit in the ledctrl register is set high, the com and seg lines will be setup as cmos output drivers to drive the led display. the com and seg lines can be set to be either active high or active low using bits in the ledctrl register. this provides 4 different timing modes. these are com low active, seg low active; com low active, seg high active; com high active, seg low active; com high active, seg high ac - tive. the com and seg lines will have a reverse polarity when in the non-active state when the display is off. for the led driver there are a total of 5 different duty cycle selections which are static, 1 / 4, 1 / 8, 1 / 12 and 1 / 16. the the frame rate of each duty cycle will be between 55hz and 75hz. lcd voltage source and biasing the time and amplitude varying signals generated by the lcd driver function require the generation of several voltage levels for their operation. the number of voltage levels used by the signal depends upon the value of the bias bit in the lcdctrl register. the device can have either r type or c type biasing selected via a configura- tion option. selecting the c type biasing will enable an in- ternal charge pump whose multiplier ratio can be selected using an additional configuration option. for r type biasing an external lcd voltage source must be supplied on pin vlcd1 to generate the internal bias- ing voltages. this could be the microcontroller power supply or some other voltage source. for the r type 1 / 2 bias selection, three voltage levels vss, va and vb are utilised. the voltage va is equal to the externally sup - plied voltage source applied to pin vlcd1. vb is gener - ated internally by the microcontroller and will have a value equal to vlcd1 / 2. for the r type 1 / 3 bias selec - tion, four voltage levels vss, va, vb and vc are uti - lised. the voltage va is equal to vlcd1, vb is equal to vlcd12 / 3 while vc is equal to vlcd1 1 / 3. in addition to selecting 1 / 2or1 / 3 bias, several values of bias resis - tor can be chosen using bits in the lcdctrl register. different values of internal bias resistors can be se - lected using the rsel0 and resel1 bits in the lcdctrl register. this along with the voltage on pin vlcd1 will determine the bias current. the connection to the vmax pin depends upon the voltage that is ap - plied to vlcd1. if the vdd voltage is greater than the voltage applied to the vlcd1 pin then the vmax pin should be connected to vdd, otherwise the vmax pin should be connected to pin vlcd1. note that no exter - nal capacitors or resistors are required to be connected if r type biasing is used. condition vmax connection vdd > vlcd1 connect vmax to vdd otherwise connect vmax to vlcd1 r type bias current vmax connection for c type biasing an external lcd voltage source must also be supplied on pin vlcd1 to generate the internal biasing voltages. the c type biasing scheme uses an in - ternal charge pump circuit, which in the case of the 1 / 3 bias selection can generate voltages higher than what is supplied on vlcd1. this feature is useful in applica - tions where the microcontroller supply voltage is less than the supply voltage required by the lcd. an addi - tional charge pump capacitor must also be connected between pins c1 and c2 to generate the necessary volt - age levels. for the c type 1 / 2 bias selection, three voltage levels vss, va and vb are utilised. the voltage va is generated internally and has a value of vlcd1. vb will have a value equal to va  0.5. for the c type 1 / 2 bias configuration vc is not used. for the c type 1/3 bias selection, four voltage levels vss, va, vb and vc are utilised. the voltage va is gen - erated internally and has a value of vlcd1  1.5. vb will have a value equal to va  2 / 3 and vc will have a value equal to va  1 / 3. the connection to the vmax pin de- pends upon the bias and the voltage that is applied to vlcd1, the details are shown in the table. note that c type biasing is not available on the 52-pin qfp package device types. on these package types, pins c1, c2 and vlcd2 are not provided. it is recommended that a 0.1 f capacitor is connected between the v1 pin and ground on the 52-pin qfp package types. it is extremely important to ensure that these charge pump generated internal voltages do not exceed the maximum vdd voltage of 5.5v. note that the c-type bias type is not available on the 52-pin qfp package type. biasing type vmax connection 1 / 3 bias vdd vlcd11.5 connect vmax to vdd otherwise connect vmax to v1 1 / 2 bias vdd vlcd1 connect vmax to vdd otherwise connect vmax to vlcd1 c type biasing vmax connection
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 34 may 21, 2012 programming considerations certain precautions must be taken when programming the lcd/led. one of these is to ensure that the display memory is properly initialised after the microcontroller is powered on. like the general purpose data memory, the contents of the display memory are in an unknown condition after power-on. as the contents of the display memory y will be mapped into the actual display, it is im - portant to initialise this memory area into a known condi - tion soon after applying power to obtain a proper display pattern. consideration must also be given to the capacitive load of the actual lcd used in the application. as the load presented to the microcontroller by lcd pixels can be generally modeled as mainly capacitive in nature, it is important that this is not excessive, a point that is partic - ularly true in the case of the com lines which may be connected to many lcd pixels. the accompanying dia - gram depicts the equivalent circuit of the lcd. one additional consideration that must be taken into ac - count is what happens when the microcontroller enters a power down condition. the lcden control bit in the lcdctrl or leden bit in the ledctrl register per - mits the display to be powered off to reduce power con - sumption. if this bit is zero, the driving signals to the display will cease, producing a blank display pattern but reducing any power consumption associated with the lcd. after power-on, note that as the lcden and leden bits will be cleared to zero, the display function will be disabled. the accompanying timing diagrams depict the display driver signals generated by the microcontroller for vari- ous values of duty and bias. the huge range of various permutations only permit a few types to be displayed here. .   . % % .   . % %   6 
  -   
&   ! ) 
  -   
&    6 
  -   
&   ! ) 

    
&    6 

    
&   ! ) 
  -   
&    6 

    
&   ! ) 

    
&  .   . % % .   . % % .   . % % .   . % % .   . % % .   . % % 6 / , 0 4 / led static mode normal operation .   . % % .   . % % .   . % %   6   /  ! ) led 1 / 4 duty, com high active, seg low active, display off   6   /   ,    ! ) 6  ! ) /  ! ) ,  ! ) lcd panel equivalent circuit
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 35 may 21, 2012   6   /  ! ) 6 .   . % %  ! ) /   ,   0 6 / , 0 6 / , 0 .   . % % .   . % % .   . % % .   . % % .   . % % led 1 / 4 duty, com high active, seg low active, normal operation   6          8   /          8 $            8 . $ . 7  .    . $ . 7  .    . $ . 7  .      6    /  $            ' ' . $ . 7  .    . $ . 7  .    . $ . 7  .    3     + ) *       -  4    6 b    /  $                 . $ . 7  .    . $ . 7  .    /  '    0       $          -  4  note: for 1 / 2 bias, va=vlcd1, vb=vlcd1 1 / 2 for both r and c type. lcd driver output  type a - 1 / 2 duty, 1 / 2 bias
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 36 may 21, 2012 3     + ) *       -  4  0       $          -  4    6 b    / b    ,  $                   6    /    ,  $            ' '   6          8   /          8   ,          8   6 b  /          8   6 b  ,          8   / b  ,          8 $            8 . $ . 7  .    . $ . 7  .    . $ . 7  .    . $ . 7  .    . $ . 7  .    . $ . 7  .    . $ . 7  .    . $ . 7  .    . $ . 7  .    . $ . 7  .    . $ . 7  .    . $ . 7  .    . $ . 7  .    /  '    note: for 1 / 2 bias, the va=vlcd1, vb=vlcd1 1 / 2 for both r and c type. lcd driver output  type a- 1 / 3 duty, 1 / 2 bias
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 37 may 21, 2012 . $  . 7 . .   /  '    . $  . 7 . .   . $  . 7 . .   . $  . 7 . .   . $  . 7 . .   . $  . 7 . .   . $  . 7 . .   . $  . 7 . .   . $  . 7 . .   . $  . 7 . .     6    /    ,  $            ' '   6          8   0   /          8   ,          8 =        
 
       
    >   6 b  /          8   0          8 3     + ) *       -  4  0       $          -  4    6 b    / b    , b    0  $                 . $  . 7 . .   . $  . 7 . .   . $  . 7 . .     6 b  ,          8 . $  . 7 . .     6 b  0          8 . $  . 7 . .   $            8 note: for 1 / 3 r type bias, the va=vlcd1, vb=vlcd1 2 / 3 and vc=vlcd1 1 / 3. for 1 / 3 c type bias, the va=vlcd1  1.5, vb=vlcd1 and vc=vlcd11 / 2. lcd driver output  type a - 1 / 4 duty, 1 / 3 bias
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 38 may 21, 2012 . $  . 7 . .   /  '    . $  . 7 . .   . $  . 7 . .   . $  . 7 . .   . $  . 7 . .   . $  . 7 . .   . $  . 7 . .   . $  . 7 . .   . $  . 7 . .     6    /    ,  $            ' '   6          8   /          8   ,          8   6 b  ,          8   6 b  /          8 . $  . 7 . .     / b  ,          8 . $  . 7 . .   $            8 3     + ) *       -  4  0       $          -  4    6 b    / b    ,  $                 . $  . 7 . .   . $  . 7 . .   note: for 1 / 3 r type bias, the va=vlcd1, vb=vlcd1 2 / 3 and vc=vlcd1 1 / 3. for 1 / 3 c type bias, the va=vlcd1  1.5, vb=vlcd1 and vc=vlcd11 / 2. lcd driver output  type a - 1 / 3 duty, 1 / 3 bias
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 39 may 21, 2012 . $ . 7 .     6   /   f f   6           f f   f f    f f   /           f f   f f   f f   6         f f  f f  f f  f f   f f   f f   f f  f f  f f  f f  f f f f  f f f f  f f f f  f f f f . $ . 7 .   . $ . 7 .   . $ . 7 .   . $ . 7 .     f f   f f   f f  f f note: for 1 / 2 bias, the va=vlcd1, vb=vlcd1 1 / 2 for both r and c type. lcd driver output  type b  1 / 2 duty, 1 / 2 bias timer/event counters the provision of timers form an important part of any microcontroller , giving the designer a means of carrying out time related functions. the devices contain several 8-bit and 16-bit count-up timers. as each timer has three different operating modes, they can be configured to op - erate as a general timer, an external event counter or as a pulse width measurement device. the provision of a prescaler to the clock circuitry of the 8-bit timer/event counter also gives added range to this timer. there are two types of registers related to the timer/event counters. the first are the registers that contain the actual value of the timer/event counter and into which an initial value can be preloaded. reading from these registers retrieves the contents of the timer/event counter. the second type of associated register is the timer control register which defines the timer options and determines how the timer/event counter is to be used. the timer/event counters can have the their clock configured to come from an internal clock source. in addition, their clock source can also be configured to come from an external timer pin. configuring the timer/event counter input clock source the internal timer
s clock can originate from various sources. the system clock source is used when the timer/event counter is in the timer mode or in the pulse width measurement mode. for the 8-bit timer/event counter this internal clock source is f sys which is also di - vided by a prescaler, the division ratio of which is condi - tioned by the timer control register, tmrnc, bits tnpsc0~ tnpsc2. for the 16-bit timer/event counter this internal clock source can be chosen from a combi - nation of internal clocks using a configuration option and the tns bit in the tmrnc register. an external clock source is used when the timer is in the event counting mode, the clock source being provided on an external timer pin tmr0, tmr1, tmr2 or tmr3 depending upon which timer is used. depending upon the condition of the tne bit, each high to low, or low to high transition on the external timer pin will increment the counter by one.
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 40 may 21, 2012 device all devices no. of 8-bit timers 3 timer name timer/event counter 0 timer/event counter 2 timer/event counter 3 timer register name tmr0 tmr2 tmr3 control register name tmr0c tmr2c tmr3c no. of 16-bit timers 1 timer name timer/event counter 1 timer register name tmr1l/tmr1h control register name tmr1c timer registers  tmr0, tmr1l/tmr1h, tmr2, tmr3 the timer registers are special function registers located in the special purpose data memory and is the place where the actual timer value is stored. for the 8-bit timer/event counters, these registers are known as tmr0, tmr2 or tmr3. for the 16-bit timer/event counter, a pair of regis- ters are required and are known as tmr1l/tmr1h. the value in the timer registers increases by one each time an internal clock pulse is received or an external transition oc- curs on the external timer pin. the timer will count from the initial value loaded by the preload register to the full count of ffh for the 8-bit timer or ffffh for the 16-bit timer at which point the timer overflows and an internal interrupt signal is generated. the timer value will then be reset with the initial preload register value and continue counting. to achieve a maximum full range count of ffh for the 8-bit timer or ffffh for the 16-bit timer, the preload reg - isters must first be cleared to all zeros. it should be noted that after power-on, the preload register will be in an unknown condition. note that if the timer/event counter is switched off and data is written to its preload registers, this data will be immediately written into the actual timer registers. however, if the timer/event counter is enabled and counting, any new data written into the preload data registers during this period will re - main in the preload registers and will only be written into the timer registers the next time an overflow occurs. for the 16-bit timer/event counter which has both low byte and high byte timer registers, accessing these reg - isters is carried out in a specific way. it must be noted when using instructions to preload data into the low byte timer register, the data will only be placed in a low byte buffer and not directly into the low byte timer register. the actual transfer of the data into the low byte timer register is only carried out when a write to its associated high byte timer register, namely tmr1h, is executed. on the other hand, using instructions to preload data into the high byte timer register will result in the data be - ing directly written to the high byte timer register. at the same time the data in the low byte buffer will be trans - ferred into its associated low byte timer register. for this reason, the low byte timer register should be written first when preloading data into the 16-bit timer registers. it must also be noted that to read the contents of the low byte timer register, a read to the high byte timer register must be executed first to latch the contents of the low byte timer register into its associated low byte buffer. af - ter this has been done, the low byte timer register can be read in the normal way. note that reading the low byte timer register will result in reading the previously latched contents of the low byte buffer and not the actual con - tents of the low byte timer register. timer control registers  tmr0c, tmr1c, tmr2c, tmr3c the flexible features of the holtek microcontroller timer/event counters enable them to operate in three different modes, the options of which are determined by the contents of their respective control register. it is the timer control register together with its corre- sponding timer registers that control the full operation of the timer/event counters. before the timers can be used, it is essential that the appropriate timer control register is fully programmed with the right data to en- sure its correct operation, a process that is normally car- ried out during program initialisation. to choose which of the three modes the timer is to oper- ate in, either in the timer mode, the event counting mode or the pulse width measurement mode, bits 7 and 6 of the corresponding timer control register, which are known as the bit pair tnm1/tnm0, must be set to the re - quired logic levels. the timer-on bit, which is bit 4 of the timer control register and known as tnon, depending upon which timer is used, provides the basic on/off con - trol of the respective timer. setting the bit high allows the counter to run, clearing the bit stops the counter. for tim - ers that have prescalers, bits 0~2 of the timer control register determine the division ratio of the input clock prescaler. the prescaler bit settings have no effect if an external clock source is used. if the timer is in the event count or pulse width measurement mode, the active transition edge level type is selected by the logic level of bit 3 of the timer control register which is known as tne. an additional tns bit in the 16-bit timer/event counter control register is used to determine the clock source for the timer/event counter.
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 41 may 21, 2012      
  # ! &                     8           
    
  # ! &        %     7          &   f   -              , 4                   , i    6 = / # / i / # / ,  >   
  
  # ! &           /   6   f  @   ' % 6   ! '
    '
      #  f f  f
    
   
 8-bit timer/event counter structure     ! 
  # ! &                   / 3  7
           
    %     7          &   f   -           +  -  7    7  f f     /   6   8 d
   7    +  -  7    / 3  
  
  # ! &          ' % /    ,      :    f  @  # 1   :    f   7 ! "       0 , 4 3  d l        0 , ;   8   f
    
  
 '
    '
      #  f f  f
    
   
 16-bit timer/event counter structure   :   ' % 6  ' % /  f
    
  
  ' %  -       $    !  5  /  / 1 "  4 ! &           
&             / a        f   
      6 a        

        !  8   6  / 
                        , 6 6 6 6 / / / /  6    ,    /    6    / 6 6 / / 6 6 / /    6 6 / 6 / 6 / 6 / 
            / a /      / a ,      / a 1      / a       / a / 3      / a 0 ,      / a 3 1      / a / ,  
  # ! &            
       / a       6 a  
         
             / 6 6 / /   6 6 / 6 /        & 
      &              
           -
                      
               
&             / a          
    

      b        f   
      6 a          
    f   
      b        

       8   
      b          h 6 h timer/event counter control register  tmrnc
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 42 may 21, 2012 configuring the timer mode in this mode, the timer/event counter can be utilised to measure fixed time intervals, providing an internal inter - rupt signal each time the timer/event counter over - flows. to operate in this mode, the operating mode select bit pair, tnm1/tnm0, in the timer control regis- ter must be set to the correct value as shown. control register operating mode select bits for the timer mode bit7 bit6 10 in this mode the internal clock, f sys , is used as the inter- nal clock for 8-bit timer/event counter 0 and f sub or f sys /4 is used as the internal clock for 16-bit timer/event counter 1. however, the clock source, f sys , for the 8-bit timer is further divided by a prescaler, the value of which is determined by the prescaler rate select bits tnpsc2~tnpsc0, which are bits 2~0 in the timer con - trol register. after the other bits in the timer control register have been setup, the enable bit tnon or tnon, which is bit 4 of the timer control register, can be set high to enable the timer/event counter to run. each time an internal clock cycle occurs, the timer/event counter increments by one. when it is full and overflows, an interrupt signal is generated and the timer/event counter will reload the value already loaded into the preload register and continue counting. the interrupt can be disabled by ensuring that the timer/event counter interrupt enable bit in the corre - sponding interrupt control register, is reset to zero. configuring the event counter mode in this mode, a number of externally changing logic events, occurring on the external timer pin, can be re - corded by the timer/event counter. to operate in this mode, the operating mode select bit pair, tnm1/tnm0, in the timer control register must be set to the correct value as shown. control register operating mode select bits for the event counter mode bit7 bit6 01 in this mode, the external timer pin, is used as the timer/event counter clock source, however it is not di- vided by the internal prescaler. after the other bits in the timer control register have been setup, the enable bit tnon, which is bit 4 of the timer control register, can be set high to enable the timer/event counter to run. if the active edge select bit, tne, which is bit 3 of the timer control register, is low, the timer/event counter will increment each time the external timer pin receives a low to high transition. if the active edge select bit is high, the counter will increment each time the external timer pin receives a high to low transition. when it is full and overflows, an interrupt signal is generated and the timer/event counter will reload the value already loaded into the preload register and continue counting. the interrupt can be disabled by ensuring that the timer/event counter interrupt enable bit in the corre - sponding interrupt control register, is reset to zero. as the external timer pin is shared with an i/o pin, to en -  4  !   8   6   /  6  -       $    !  5  " 8   
      b          h 6 h ! &           
&             / a        f   
      6 a        

            
               
&             / a          
    

      b        f   
      6 a          
    f   
      b        

      
  # ! &            
       / a       6 a  
       / 6 6 / /   6 6 / 6 /        & 
      &             
           -
                    
           
     *       / a  f   7  = 0 , 4 3  d l     0 , ;   > 6 a  f  @  # 1   timer/event counter control register  tmrnc      
                         
   ?  / 
   ?  , 
   ?  8 
   ?  8  ?  / timer mode timing chart
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 43 may 21, 2012 sure that the pin is configured to operate as an event counter input pin, two things have to happen. the first is to ensure that the operating mode select bits in the timer control register place the timer/event counter in the event counting mode, the second is to ensure that the port control register configures the pin as an in - put. it should be noted that in the event counting mode, even if the microcontroller is in the power down mode, the timer/event counter will continue to record exter - nally changing logic events on the timer input pin. as a result when the timer overflows it will generate a timer interrupt and corresponding wake-up source. configuring the pulse width measurement mode in this mode, the timer/event counter can be utilised to measure the width of external pulses applied to the ex - ternal timer pin. to operate in this mode, the operating mode select bit pair, tnm1/tnm0, in the timer control register must be set to the correct value as shown. control register operating mode select bits for the pulse width measurement mode bit7 bit6 11 in this mode the internal clock, f sys , is used as the inter - nal clock for the 8-bit timer/event counter and f sub or f sys /4 is used as the internal clock for the 16-bit timer/event counter. however, the clock source, f sys , for the 8-bit timer is further divided by a prescaler, the value of which is determined by the prescaler rate se- lect bits tnpsc2~tnpsc0, which are bits 2~0 in the timer control register. after the other bits in the timer control register have been setup, the enable bit tnon, which is bit 4 of the timer control register, can be set high to enable the timer/event counter, however it will not actually start counting until an active edge is re- ceived on the external timer pin. if the active edge select bit tne, which is bit 3 of the timer control register, is low, once a high to low transi - tion has been received on the external timer pin, the timer/event counter will start counting until the external timer pin returns to its original high level. at this point the enable bit will be automatically reset to zero and the timer/event counter will stop counting. if the active edge select bit is high, the timer/event counter will be - gin counting once a low to high transition has been re - ceived on the external timer pin and stop counting when the external timer pin returns to its original low level. as before, the enable bit will be automatically reset to zero and the timer/event counter will stop counting. it is im - portant to note that in the pulse width measurement mode, the enable bit is automatically reset to zero when the external control signal on the external timer pin re - turns to its original level, whereas in the other two modes the enable bit can only be reset to zero under program control. the residual value in the timer/event counter, which can now be read by the program, therefore represents the length of the pulse received on the external timer pin. as the enable bit has now been reset, any further transitions on the external timer pin will be ignored. not until the enable bit is again set high by the program can the timer begin further pulse width measurements. in this way, single shot pulse measurements can be easily made. it should be noted that in this mode the timer/event counter is controlled by logical transitions on the exter- nal timer pin and not by the logic level. when the timer/event counter is full and overflows, an interrupt signal is generated and the timer/event counter will re- load the value already loaded into the preload register and continue counting. the interrupt can be disabled by ensuring that the timer/event counter interrupt enable bit in the corresponding interrupt control register, is re- set to zero. as the external timer pin is shared with an i/o pin, to en - sure that the pin is configured to operate as a pulse width measurement pin, two things have to happen. the 
  ? , ! "       ! &        
        
  ? 0 
  ? / event counter mode timing chart ? / ? , ? 0 ? 1 
  ! "          
      8    -
    ! k 6                    
        pulse width measure mode timing chart
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 44 may 21, 2012 first is to ensure that the operating mode select bits in the timer control register place the timer/event coun - ter in the pulse width measurement mode, the second is to ensure that the port control register configures the pin as an input. programmable frequency divider  pfd the programmable frequency divider provides a means of producing a variable frequency output suitable for applications requiring a precise frequency generator. the pfd output is pin-shared with the i/o pin pa3. the pfd function is selected via configuration option, how - ever, if not selected, the pin can operate as a normal i/o pin. the clock source for the pfd circuit can originate from either timer/event counter 0 or timer/event counter 1 overflow signal selected via configuration option. the output frequency is controlled by loading the required values into the timer registers and prescaler registers to give the required division ratio. the timer will begin to count-up from this preload register value until full, at which point an overflow signal is generated, causing the pfd output to change state. the timer will then be auto - matically reloaded with the preload register value and continue counting-up. for the pfd output to function, it is essential that the corre- sponding bit of the port a control register pac bit 3 is setup as an output. if setup as an input the pfd output will not function, however, the pin can still be used as a normal in- put pin. the pfd output will only be activated if bit pa3 is set to  1  . this output data bit is used as the on/off control bit for the pfd output. note that the pfd output will be low if the pa3 output data bit is cleared to  0  . using this method of frequency generation, and if a crystal oscillator is used for the system clock, very pre - cise values of frequency can be generated. prescaler bits tnpsc0~tnpsc2 of the control register can be used to define the pre-scaling stages of the internal clock source of the timer/event counter. the timer/event counter overflow signal can be used to generate signals for the pfd and timer interrupt. i/o interfacing the timer/event counter, when configured to run in the event counter or pulse width measurement mode, re - quire the use of external pins for correct operation. as these pins are shared pins they must be configured cor - rectly to ensure they are setup for use as timer/event counter inputs and not as a normal i/o pins. this is im - plemented by ensuring that the mode select bits in the timer/event counter control register, select either the event counter or pulse width measurement mode. addi - tionally the port control register must be set high to en - sure that the pin is setup as an input. any pull-high resistor on these pins will remain valid even if the pin is used as a timer/event counter input. timer/event counter pins internal filter the external timer/event counter pins are connected to an internal filter to reduce the possibility of unwanted event counting events or inaccurate pulse width mea- surements due to adverse noise or spikes on the exter- nal timer/event counter input signal. as this internal filter circuit will consume a limited amount of power, a configuration option is provided to switch off the filter function, an option which may be beneficial in power sensitive applications, but in which the integrity of the in- put signal is high. care must be taken when using the fil- ter on/off configuration option as it will be applied not only to both external timer/event counter pins but also to the external interrupt input pins. individual timer/event counter or external interrupt pins cannot be selected to have a filter on/off function. 
    &   f   -  ' %    *  $ 0  %     ' %            $ 0 pfd output control
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 45 may 21, 2012 programming considerations when configured to run in the timer mode, the internal system clock is used as the timer clock source and is therefore synchronised with the overall operation of the microcontroller . in this mode when the appropriate timer register is full, the microcontroller will generate an inter - nal interrupt signal directing the program flow to the re - spective internal interrupt vector. for the pulse width measurement mode, the internal system clock is also used as the timer clock source but the timer will only run when the correct logic condition appears on the external timer input pin. as this is an external event and not syn - chronized with the internal timer clock, the microcontroller will only see this external event when the next timer clock pulse arrives. as a result, there may be small differences in measured values requiring program - mers to take this into account during programming. the same applies if the timer is configured to be in the event counting mode, which again is an external event and not synchronised with the internal system or timer clock. when the timer/event counter is read, or if data is writ - ten to the preload register, the clock is inhibited to avoid errors, however as this may result in a counting error, this should be taken into account by the programmer. care must be taken to ensure that the timers are properly in - itialised before using them for the first time. the associ- ated timer enable bits in the interrupt control register must be properly set otherwise the internal interrupt associated with the timer will remain inactive. the edge select, timer mode and clock source control bits in timer control regis- ter must also be correctly set to ensure the timer is prop- erly configured for the required application. it is also important to ensure that an initial value is first loaded into the timer registers before the timer is switched on; this is because after power-on the initial values of the timer reg - isters are unknown. after the timer has been initialised the timer can be turned on and off by controlling the en - able bit in the timer control register. note that setting the timer enable bit high to turn the timer on, should only be executed after the timer mode bits have been properly setup. setting the timer enable bit high together with a mode bit modification, may lead to improper timer oper - ation if executed as a single timer control register byte write instruction. when the timer/event counter overflows, its corre - sponding interrupt request flag in the interrupt control register will be set. if the timer interrupt is enabled this will in turn generate an interrupt signal. however irre - spective of whether the interrupts are enabled or not, a timer/event counter overflow will also generate a wake-up signal if the device is in a power-down condi - tion. this situation may occur if the timer/event counter is in the event counting mode and if the external signal continues to change state. in such a case, the timer/event counter will continue to count these exter - nal events and if an overflow occurs the device will be woken up from its power-down condition. to prevent such a wake-up from occurring, the timer interrupt re - quest flag should first be set high before issuing the halt instruction to enter the power down mode. timer program example this program example shows how the timer/event counter registers are setup, along with how the inter- rupts are enabled and managed. note how the timer/event counter is turned on, by setting bit 4 of the timer control register. the timer/event counter can be turned off in a similar way by clearing the same bit. this example program sets the timer/event counter to be in the timer mode, which uses the internal system clock as the clock source. org 04h ; external interrupt vector reti org 08h ; timer/event counter 0 interrupt vector jmp tmrint ; jump here when the timer/event counter 0 overflows : org 20h ; main program ;internal timer/event counter 0 interrupt routine tmrint: : ; timer/event counter 0 main program placed here : reti : : begin: ;setup timer 0 registers mov a,09bh ; setup timer 0 preload value mov tmr0,a; mov a,081h ; setup timer 0 control register mov tmr0c,a ; timer mode and prescaler set to /2 ; setup interrupt register mov a,009h ; enable master interrupt and timer interrupt mov int0c,a set tmr0c.4 ; start timer/event counter 0 - note mode bits must be previously setup
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 46 may 21, 2012 pulse width modulator the devices contains a series of pulse width modula - tion, pwm, outputs. useful for such applications such as motor speed control, the pwm function provides an out - put with a fixed frequency but with a duty cycle that can be varied by setting particular values into the corre - sponding pwm register. part no. channels pwm mode output pin register names all devices 4 8+4 pd0~ pd3 pwm0l~ pwm3l pwm0h~ pwm3h pwm overview a register pair, located in the data memory is assigned to each pulse width modulator output and are known as the pwm registers. it is in each register pair that the 12-bit value, which represents the overall duty cycle of one modulation cycle of the output waveform, should be placed. the pwm registers also contain the enable/dis - able control bit for the pwm outputs. to increase the pwm modulation frequency, each modulation cycle is modulated into sixteen individual modulation sub-sections, known as the 8+4 mode. note that it is only necessary to write the required modulation value into the corresponding pwm register as the subdivision of the waveform into its sub-modulation cycles is imple- mented automatically within the microcontroller hard- ware. the pwm clock source is the system clock f sys . this method of dividing the original modulation cycle into a further 16 sub-cycles enables the generation of higher pwm frequencies, which allow a wider range of applications to be served. as long as the periods of the generated pwm pulses are less than the time constants of the load, the pwm output will be suitable as such long time constant loads will average out the pulses of the pwm output. the difference between what is known as the pwm cycle frequency and the pwm modulation fre - quency should be understood. as the pwm clock is the system clock, f sys , and as the pwm value is 12-bits wide, the overall pwm cycle frequency is f sys /4096. however, when in the 8+4 mode of operation, the pwm modulation frequency will be f sys /256. pwm modulation frequency pwm cycle frequency pwm cycle duty f sys /256 f sys /4096 (pwm register value)/4096 8+4 pwm mode modulation each full pwm cycle, as it is 12-bits wide, has 4096 clock periods. however, in the 8+4 pwm mode, each pwm cy - cle is subdivided into sixteen individual sub-cycles known as modulation cycle 0 ~ modulation cycle 15, denoted as  i  in the table. each one of these sixteen sub-cycles con - tains 256 clock cycles. in this mode, a modulation fre - quency increase of sixteen is achieved. the 12-bit pwm register value, which represents the overall duty cycle of the pwm waveform, is divided into two groups. the first group which consists of bit4~bit11 is denoted here as the dc value. the second group which consists of bit0~bit3 is known as the ac value. in the 8+4 pwm mode, the duty cycle value of each of the two modulation sub-cycles is shown in the following table. parameter ac (0~15) dc (duty cycle) modulation cycle i (i=0~15) i ac dc+1 256 iac dc 256 8+4 mode modulation cycle values the accompanying diagram illustrates the waveforms associated with the 8+4 mode of pwm operation. it is important to note how the single pwm cycle is subdi- vided into 16 individual modulation cycles, numbered 0~15 and how the ac value is related to the pwm value. pwm output control the four pwm0~pwm3 outputs are shared with pins pd0~pd3. to operate as a pwm output and not as an i/o pin, bit 0 of the relevant pwm register bit must be set high. a zero must also be written to the corresponding bit in the pdc port control register, to ensure that the pwm0 output pin is setup as an output. after these two initial steps have been carried out, and of course after the required pwm 12-bit value has been written into the pwm register pair register, writing a 1 to the corre - sponding pd data register will enable the pwm data to appear on the pin. writing a 0 to the bit will disable the pwm output function and force the output low. in this way, the port d data output register bits, can also be used as an on/off control for the pwm function. note that if the enable bit in the pwm register is set high to enable the pwm function, but a 1 has been written to its corresponding bit in the pdc control register to con - figure the pin as an input, then the pin can still function as a normal input line, with pull-high resistor selections.
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 47 may 21, 2012 6 -    $    $ !  5  7 1 "  4  6      #  f f       / a           6 a   #  
      8   
      b          h 6 h     $  .     
   6 i 0     %  .     
   1 i / /    ! 8 6 0 /,  4  6  / / 5/ 6 4 3 2 1    6 + i    0 + +  -  7       
        6 d i    0 d d
   7       
     pwm register pairs f  @  # ,    c    e  k / 3 6 6 c    e  k / 3 6 /    c    e  k / 3 6 ,    c    e  k / 3 / 2            a  1 6 5 3 # f  @  / 6 6 # , 2 3 / 6 / # , 2 3 / 6 / # , 2 3 / 6 / # , 2 3       
      6          
   
   a  , 2 3 # f  @        
      /       
      ,       
      / 2       
      6 / 6 6 # , 2 3 / 6 6 # , 2 3 / 6 6 # , 2 3 / 6 / # , 2 3 / 6 6 # , 2 3 / 6 / # , 2 3 / 6 / # , 2 3 / 6 / # , 2 3 / 6 6 # , 2 3 / 6 6 # , 2 3 / 6 6 # , 2 3 / 6 6 # , 2 3 / 6 6 # , 2 3 / 6 / # , 2 3 / 6 / # , 2 3 / 6 / # , 2 3 8+4 pwm mode pwm programming example the following sample program shows how the pwm output is setup and controlled. mov a,64h ; setup pwm0 value to 1600 decimal which is 640h mov pwm0h,a ; setup pwm0h register value clr pwm0l ; setup pwm0l register value clr pdc.0 ; setup pin pd0 as an output set pwm0en ; set the pwm0 enable bit set pd.0 ; enable the pwm0 output :: :: clr pd.0 ; pwm0 output disabled  pd0 will remain low
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 48 may 21, 2012 analog to digital converter the need to interface to real world analog signals is a common requirement for many electronic systems. however, to properly process these signals by a microcontroller , they must first be converted into digital signals by a/d converters. by integrating the a/d con - version electronic circuitry into the microcontroller , the need for external components is reduced significantly with the corresponding follow-on benefits of lower costs and reduced component space requirements. a/d overview the device contains an 8-channel analog to digital con - verter which can directly interface to external analog sig - nals, such as that from sensors or other control signals and convert these signals directly into either a 12-bit dig - ital value. part no. input channels conversion bits input pins all devices 8 12 pb0~pb7 the accompanying block diagram shows the overall in - ternal structure of the a/d converter, together with its as - sociated registers. a/d converter data registers  adrl, adrh the device, which has an internal 12-bit a/d converter, requires two data registers, a high byte register, known as adrh, and a low byte register, known as adrl. after the conversion process takes place, these registers can be directly read by the microcontroller to obtain the digit- ised conversion value. only the high byte register, adrh, utilises its full 8-bit contents. the low byte regis- ter utilises only 4 bit of its 8-bit contents as it contains only the lowest bits of the 12-bit converted value. in the following table, d0~d11 is the a/d conversion data result bits. register bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adrl d3 d2 d1 d0  adrh d11 d10 d9 d8 d7 d6 d5 d4 a/d data registers a/d converter control registers  adcr, acsr to control the function and operation of the a/d con - verter, two control registers known as adcr and acsr are provided. these 8-bit registers define functions such as the selection of which analog channel is con - nected to the internal a/d converter, which pins are used as analog inputs and which are used as normal i/os, the a/d clock source as well as controlling the start function and monitoring the a/d converter end of con - version status. the acs2~acs0 bits in the adcr register define the channel number. as the device contains only one actual analog to digital converter circuit, each of the individual 8 analog inputs must be routed to the converter. it is the function of the acs2~acs0 bits in the adcr register to determine which analog channel is actually connected to the internal a/d converter. the adcr control register also contains the pcr2~pcr0 bits which determine which pins on port b are used as analog inputs for the a/d converter and which pins are to be used as normal i/o pins. if the 3-bit address on pcr2~pcr0 has a value of  111  , then all eight pins, namely an0~an7 will all be set as analog in- puts. note that if the pcr2~pcr0 bits are all set to zero, then all the port b pins will be setup as normal i/os and the internal a/d converter circuitry will be powered off to reduce the power consumption.    * %
&
     8 $      
    $ %  7 6 # $ 8 6  7 / # $ 8 /  7 4 # $ 8 4 $ # %    f      .       $ %  + $ %  d $ # %  %      
       6 i   , $ %  6 i $ %  ,   $   !  7 $ %    
    $ .   $ # %  )     $ . % % $ # %    

&     -        $ %  8 7  7
 $ # %  !     f  @  a/d converter structure
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 49 may 21, 2012 the start bit in the register is used to start and reset the a/d converter. when the microcontroller sets this bit from low to high and then low again, an analog to digital conversion cycle will be initiated. when the start bit is brought from low to high but not low again, the eocb bit in the adcr register will be set to a 1 and the analog to digital converter will be reset. it is the start bit that is used to control the overall on/off operation of the internal analog to digital converter. the eocb bit in the adcr register is used to indicate when the analog to digital conversion process is com - plete. this bit will be automatically set to 0 by the microcontroller after a conversion cycle has ended. in addition, the corresponding a/d interrupt request flag will be set in the interrupt control register, and if the inter - rupts are enabled, an appropriate internal interrupt sig - nal will be generated. this a/d internal interrupt signal will direct the program flow to the associated a/d inter - nal interrupt address for processing. if the a/d internal interrupt is disabled, the microcontroller can be used to poll the eocb bit in the adcr register to check whether it has been cleared as an alternative method of detect - ing the end of an a/d conversion cycle. the clock source for the a/d converter, which originates from the system clock f sys , is first divided by a division ratio, the value of which is determined by the adcs2, adcs1 and adcs0 bits in the acsr register. controlling the on/off function of the a/d converter cir - cuitry is implemented using the adonb bit in the acsr register and the value of the pcr bits in the adcr reg- ister. both the adonb bit must cleared to 0 and the value of the pcr bits must have a non-zero value for the a/d converter to be enabled. pcr adonb a/d 0 x off >0 0 on > 0 1 off although the a/d clock source is determined by the sys - tem clock f sys , and by bits adcs2, adcs1 and adcs0, there are some limitations on the maximum a/d clock source speed that can be selected. as the minimum value of permissible a/d clock period, t ad ,is0.5  s, care must be taken for system clock speeds in excess of 4mhz. for system clock speeds in excess of 4mhz, the adcs2, adcs1 and adcs0 bits should not be set to  000 . doing so will give a/d clock periods that are less than the mini - mum a/d clock period which may result in inaccurate a/d conversion values. refer to the following table for exam - ples, where values marked with an asterisk * show where, depending upon the device, special care must be taken, as the values may be less than the specified minimum a/d clock period.  4  6   $     ,   /   6 $  , $  / $  6 !  7  0      $          $ # %           7  $ # %        f
    
  !    f  $ # %   &   
  f    / a  $ # %   &   
  - 

    
        6 a  $ # %   &   
                $ # %   &   
 6    /    6  a       6    /  a        $ # %   &              !  7     h / h $  , 6 6 6 6 / / / / $  / 6 6 / / 6 6 / / $  6 6 / 6 / 6 / 6 / $ 8 6 $ 8 / $ 8 , $ 8 0 $ 8 1 $ 8 2 $ 8 3 $ 8 4   , 6 6 6 6 / / / /   / 6 6 / / 6 6 / /   6 6 / 6 / 6 / 6 /      7  $ # %               f f  7 6            $ 8 6  7 6 i  7 /            $ 8 6 i $ 8 /  7 6 i  7 ,            $ 8 6 i $ 8 ,   7 6 i  7 0            $ 8 6 i $ 8 0   7 6 i  7 1            $ 8 6 i $ 8 1  7 6 i  7 2            $ 8 6 i $ 8 2  7 6 i  7 4            $ 8 6 i $ 8 4 a/d converter control register  adcr
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 50 may 21, 2012       $ # %   &         *       8   
      b          h 6 h $ # %   #  f f        
 / a  
     6 a       '                      %     $     6 $ %  / $ %  6 $ %  / 6 6 / / 6 6 / / $ %  6 6 / 6 / 6 / 6 / a          * # , a          * #  a          * # 0 , a     f
  a          * a          * # 1 a          * # / 3 a     f
   4  !   $ %  8 7 $ %  , $ %  , 6 6 6 6 / / / / a/d converter control register  acsr f sys a/d clock period (t ad ) adcs2, adcs1, adcs0=000 (f sys /2) adcs2, adcs1, adcs0=001 (f sys /8) adcs2, adcs1, adcs0=010 (f sys /32) adcs2, adcs1, adcs0=011 1mhz 2s8 s3 2 s undefined 2mhz 1s4 s1 6 s undefined 4mhz 500ns 2s8 s undefined 8mhz 250ns* 1s4 s undefined 12mhz 167ns* 667ns 2.67s undefined a/d clock period examples a/d input pins all of the a/d analog input pins are pin-shared with the i/o pins on port b. bits pcr2~pcr0 in the adcr regis- ter, determine whether the input pins are setup as nor- mal port b input/output pins or whether they are setup as analog inputs. in this way, pins can be changed under program control to change their function from normal i/o operation to analog inputs and vice versa. pull-high re - sistors, which are setup through register programming, apply to the input pins only when they are used as nor - mal i/o pins, if setup as a/d inputs the pull-high resistors will be automatically disconnected. note that it is not necessary to first setup the a/d pin as an input in the pbc port control register to enable the a/d input as when the pcr2~pcr0 bits enable an a/d input, the sta - tus of the port control register will be overridden. the a/d converter has its own power supply pins avdd and avss and a vref reference pin. the analog input val - ues must not be allowed to exceed the value of vref. initialising the a/d converter the internal a/d converter must be initialised in a special way. each time the port b a/d channel selection bits are modified by the program, the a/d converter must be re-initialised. if the a/d converter is not initialised after the channel selection bits are changed, the eocb flag may have an undefined value, which may produce a false end of conversion signal. to initialise the a/d converter after the channel selection bits have changed, then, within a time frame of one to ten instruction cycles, the start bit in the adcr register must first be set high and then im- mediately cleared to zero. this will ensure that the eocb flag is correctly set to a high condition. summary of a/d conversion steps the following summarises the individual steps that should be executed in order to implement an a/d con - version process.  step 1 select the required a/d conversion clock by correctly programming bits adcs2, adcs1 and adcs0 in the register.  step 2 enable the a/d by clearing the in the acsr register to zero.  step 3 select which channel is to be connected to the internal a/d converter by correctly programming the acs2~acs0 bits which are also contained in the reg - ister.  step 4 select which pins on port b are to be used as a/d in - puts and configure them as a/d input pins by correctly programming the pcr2~pcr0 bits in the adcr reg - ister. note that this step can be combined with step 2 into a single adcr register programming operation.
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 51 may 21, 2012  step 5 if the interrupts are to be used, the interrupt control reg - isters must be correctly configured to ensure the a/d converter interrupt function is active. the master inter - rupt control bit, emi, in the intc0 interrupt control reg- ister must be set to  1  , the multi-function interrupt enable bit, emfi, in the intc1 register and the a/d converter interrupt bit, eadi, in the intc1 register must also be set to  1  .  step 6 the analog to digital conversion process can now be initialised by setting the start bit in the adcr regis- ter from 0 to 1 and then to 0 again. note that this bit should have been originally set to 0.  step 7 to check when the analog to digital conversion pro - cess is complete, the eocb bit in the adcr register can be polled. the conversion process is complete when this bit goes low. when this occurs the a/d data registers adrl and adrh can be read to obtain the conversion value. as an alternative method if the in - terrupts are enabled and the stack is not full, the pro - gram can wait for an a/d interrupt to occur. note: when checking for the end of the conversion process, if the method of polling the eocb bit in the adcr register is used, the interrupt enable step above can be omitted. the accompanying diagram shows graphically the vari - ous stages involved in an analog to digital conversion process and its associated timing. the setting up and operation of the a/d converter func - tion is fully under the control of the application program as there are no configuration options associated with the a/d converter. after an a/d conversion process has been initiated by the application program, the microcontroller internal hardware will begin to carry out the conversion, during which time the program can continue with other functions. the time taken for the a/d conversion is 16t ad where t ad is equal to the a/d clock period. programming considerations when programming, special attention must be given to the a/d channel selection bits in the register. if these bits are all cleared to zero no external pins will be se- lected for use as a/d input pins allowing the pins to be used as normal i/o pins. when this happens the power supplied to the internal a/d circuitry will be reduced re- sulting in a reduction of supply current. this ability to re- duce power by turning off the internal a/d function by clearing the a/d channel selection bits may be an impor - tant consideration in battery powered applications. the adonb bit in the acsr register can also be used to power down the a/d function. another important programming consideration is that when the a/d channel selection bits change value, the a/d converter must be re-initialised. this is achieved by pulsing the start bit in the adcr register immediately after the channel selection bits have changed state. the exception to this is where the channel selection bits are all cleared, in which case the a/d converter is not re - quired to be re-initialised. a/d programming example the following two programming examples illustrate how to setup and implement an a/d conversion. in the first example, the method of polling the eocb bit in the adcr register is used to detect when the conversion cycle is complete, whereas in the second example, the a/d interrupt is used to determine when the conversion is complete.  $ % $ # %   &   
  
 6 6 6 7 " " " 7 / 6 6 7 6 / 6 7   $   !  7   , i   6 $  , i $  6   -          !    f  $ # %  &   
 / a  %  f
       f
    
 , a                  $ # %    *         f    b  f  @  # , b  f  @  # 1 b  f  @  #  b  f  @  # / 3     f  @  # 0 ,  $ %  k 1  $ %  $ % k   $ %  ? m  $ % n  k 
       f  $ %        
 8    a         f  $ # %  &   
       $ # %  &      $ # %    
  
    $ %   6 6 6 7        f  $ # %  &   
       $ # %  &      / 6 / 7 6 6 / 7        f  $ # %  &   
       $ # %  &      !    f  $ # %  &   
 $ # %    
  
    $ %   6 6 6 7 " " " 7 $ %        8 $ %  8 7  f f  f f     8 ,    $ % $ # %   &   
  
 a/d conversion timing
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 52 may 21, 2012 example: using an eocb polling method to detect the end of conversion clr eadi ; disable adc interrupt mov a,00000001b mov acsr,a ; select f sys /8 as a/d clock and turn on adonb bit mov a,00100000b ; setup adcr register to configure port pb0~pb3 ; as a/d inputs mov adcr,a ; and select an0 to be connected to the a/d converter : : ; as the port b channel bits have changed the ; following start ; signal (0-1-0) must be issued ; instruction cycles : start_conversion: clr start set start ; reset a/d clr start ; start a/d polling_eoc: sz eocb ; poll the adcr register eocb bit to detect end ; of a/d conversion jmp polling_eoc ; continue polling mov a,adrl ; read low byte conversion result value mov adrl_buffer,a ; save result to user defined register mov a,adrh ; read high byte conversion result value mov adrh_buffer,a ; save result to user defined register : jmp start_conversion ; start next a/d conversion example: using the interrupt method to detect the end of conversion clr eadi ; disable adc interrupt mov a,00000001b mov acsr,a ; select f sys /8 as a/d clock and turn on adonb bit mov a,00100000b ; setup adcr register to configure port pb0~pb3 ; as a/d inputs mov adcr,a ; and select an0 to be connected to the a/d : ; as the port b channel bits have changed the ; following start signal(0-1-0) must be issued ; : start_conversion: clr start set start ; reset a/d clr start ; start a/d clr adf ; clear adc interrupt request flag set eadi ; enable adc interrupt set emfi ; enable multi-function interrupt set emi ; enable global interrupt : : : ; adc interrupt service routine adc_: mov acc_stack,a ; save acc to user defined memory a,status mov status_stack,a ; save status to user defined memory : : mov a,adrl ; read low byte conversion result value mov adrl_buffer,a ; save result to user defined register mov a,adrh ; read high byte conversion result value mov adrh_buffer,a ; save result to user defined register : : exit__isr: mov a,status_stack mov status,a ; restore status from user defined memory mov a,acc_stack ; restore acc from user defined memory clr adf ; clear adc interrupt flag reti
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 53 may 21, 2012 a/d transfer function as the device contain a 12-bit a/d converter, its full-scale converted digitised value is equal to fffh. since the full-scale analog input value is equal to the vdd voltage, this gives a single bit analog input value of v dd /4096. the diagram show the ideal transfer function between the analog input value and the digitised output value for the a/d converter. note that to reduce the quantisation error, a 0.5 lsb off- set is added to the a/d converter input. except for the digitised zero value, the subsequent digitised values will change at a point 0.5 lsb below where they would change without the offset, and the last full scale digitised value will change at a point 1.5 lsb below the v dd level. serial interface function the device contains a serial interface function, which includes both the four line spi interface and the two line i 2 c interface types, to allow an easy method of commu - nication with external peripheral hardware. having rela - tively simple communication protocols, these serial interface types allow the microcontroller to interface to external spi or i 2 c based hardware such as sensors, flash or eeprom memory, etc. the sim interface pins are pin-shared with other i/o pins therefore the sim in - terface function must first be selected using a configura - tion option. as both interface types share the same pins and registers, the choice of whether the spi or i 2 c type is used is made using a bit in an internal register. spi interface the spi interface is often used to communicate with ex - ternal peripheral devices such as sensors, flash or eeprom memory devices etc. originally developed by motorola, the four line spi interface is a synchronous serial data interface that has a relatively simple commu - nication protocol simplifying the programming require - ments when communicating with external hardware devices. the communication is full duplex and operates as a slave/master type, where the mcu can be either master or slave. although the spi interface specification can control multiple slave devices from a single master, here, as only a single select pin, scs , is provided only one slave device can be connected to the spi bus.  spi interface operation the spi interface is a full duplex synchronous serial data link. it is a four line interface with pin names sdi, sdo, sck and scs . pins sdi and sdo are the serial data input and serial data output lines, sck is the serial clock line and scs is the slave select line. as the spi interface pins are pin-shared with normal i/o pins and with the i 2 c function pins, the spi interface must first be enabled by selecting the sim enable con - figuration option and setting the correct bits in the simctl0/simctl2 register. after the spi configura - tion option has been configured it can also be addi - tionally disabled or enabled using the simen bit in the simctl0 register. communication between devices connected to the spi interface is carried out in a slave/master mode with all data transfer initiations be - ing implemented by the master. the master also con - trols the clock signal. as the device only contains a single scs pin only one slave device can be utilised. the spi function in this device offers the following fea - tures:  full duplex synchronous data transfer  both master and slave modes  lsb first or msb first data transmission modes  transmission complete flag ' ' ! d =          > $ # %   &   
       ' ' ' d ' ' % d 6 0 d 6 , d 6 / d 6 < 2  +  7 6 / , 0 1 6 5 0 1 6 5 1 1 6 5 2 1 6 5 3 $          .       / < 2  +  7 . % % 1 6 5 3 ideal a/d transfer function % . -  $    % . % +  8   ;  %   %     ;  %   %    spi master/slave connection
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 54 may 21, 2012 %     7    %   
 %   
   %   " #  "   
f     
    7           f
    
  
   '  '    !     # %
       +  '      * !    #     
         *            f  @  f   7 
  # ! &          ;  
   
 f
    
  
  ! 8  
 !     # %
     ; ! )  
 ;   +  
 spi block diagram  rising or falling active clock edge  wcol and csen bit enabled or disable select the status of the spi interface pins is determined by a number of factors such as whether the device is in the master or slave mode and upon the condition of cer - tain control bits such as csen, simen and scs .in the table i, z represents an input floating condition. there are several configuration options associated with the spi interface. one of these is to enable the sim function which selects the sim pins rather than normal i/o pins. note that if the configuration option does not select the sim function then the simen bit in the simctl0 register will have no effect. another two sim configuration options determine if the csen and wcol bits are to be used. configuration option function sim function sim interface or i/o pins spi csen bit enable/disable spi wcol bit enable/disable spi interface configuration options spi registers there are three internal registers which control the over - all operation of the spi interface. these are the simdr data register and two control registers simctl0 and simctl2. note that the simctl1 register is only used by the i 2 c interface. pin master/salve simen=0 master  simen=1 slave  simen=1 csen=0 csen=1 csen=0 csen=1 scs =0 csen=1 scs =1 scs zzlzi , zi , z s d ozooooz sdi z i, z i, z i, z i, z z sck z h: ckpol=0 l: ckpol=1 h: ckpol=0 l: ckpol=1 i, z i, z z note: z floating, h output high, l output low, i input, o output level, i,z input floating (no pull-high) spi interface pin status
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 55 may 21, 2012 % . -        $    8   
      b          o 6 h    #  ,   #  f       / a       6 a  
       
        *             
        -        #  ,        #    &        *          ,         /         6  6    ! 8      b  f  @  # 1      b  f  @  # / 3      b  f  @  # 3 1      b  f   7      b  
  # ! &          6       # ,    &   ,     8        6 6 6 6 / / / / 6 6 / / 6 6 / /  4    /    6    , 6 / 6 / 6 / 6 /  ; ! 8  ;   /  ;   6 spi/i 2 c control register  simctl0 % . -        $     4    
 #   
&         f    / a  f

    6 a 
         
     

  f    / a    

 6 a      

   
      / a       6 a     f    
 %      
f        / a    7 6 a  +  7       *  !          / a        "  6 a        "        *      
  / a        "  6 a        "  8   
      b          h 6 h  6   +   '  ! 8  +  ; ! ) ;   + spi control register  simctl2 % . -        $     4   
&    *  -       f    / a      *  -       6 a   *  -       8   
      b          h 6 h                 # - 
     (      f    / a    (               6 a    (           - 
     
   *  -       f    / a    o    *  -      6 a   *  -         
 #   
&      / a     
     6 a    
&       ,           f    / a      6 a           
                f    / a       6 a          %         f    f    / a      f         6 a      f             6 d  :  : $ ;     : $ ; d 7 7 d $ $  d ' i 2 c control register  simctl1
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 56 may 21, 2012 the simdr register is used to store the data being transmitted and received. the same register is used by both the spi and i 2 c functions. before the microcontroller writes data to the spi bus, the actual data to be transmitted must be placed in the simdr reg - ister. after the data is received from the spi bus, the microcontroller can read it from the simdr register. any transmission or reception of data from the spi bus must be made via the simdr register. bit76543210 label sd7 sd6 sd5 sd4 sd3 sd2 sd1 sd0 r/w r/w r/w r/w r/w r/w r/w r/w r/w por xxxxxxxx there are also two control registers for the spi inter - face, simctl0 and simctl2. note that the simctl2 register also has the name simar which is used by the i 2 c function. the simctl1 register is not used by the spi function, only by the i 2 c function. register simctl0 is used to control the enable/disable function and to set the data transmission clock frequency. al - though not connected with the spi function, the simctl0 register is also used to control the peripheral clock prescaler. register simctl2 is used for other control functions such as lsb/msb selection, write colli- sion flag etc. the following gives further explanation of each simctl1 register bit:  simidle the simidle bit is used to select if the spi interface continues running when the device is in the idle mode. setting the bit high allows the spi interface to maintain operation when the device is in the idle mode. clearing the bit to zero disables any spi opera - tions when in the idle mode. this spi/i 2 c idle mode control bit is located at clkmod register bit4.  simen the bit is the overall on/off control for the spi inter - face. when the simen bit is cleared to zero to disable the spi interface, the sdi, sdo, sck and scs lines will be in a floating condition and the spi operating current will be reduced to a minimum value. when the bit is high the spi interface is enabled. the sim config - uration option must have first enabled the sim inter - face for this bit to be effective. note that when the simen bit changes from low to high the contents of the spi control registers will be in an unknown condi - tion and should therefore be first initialised by the ap - plication program.  sim0~sim2 these bits setup the overall operating mode of the sim function. as well as selecting if the i 2 c or spi function, they are used to control the spi master/slave selec - tion and the spi master clock frequency. the spi clock is a function of the system clock but can also be chosen to be sourced from the timer/event counter. if the spi slave mode is selected then the clock will be supplied by an external master device. sim0 sim1 sim2 spi master/slave clock control and i2c enable 0 0 0 spi master, f sys /4 0 0 1 spi master, f sys /16 0 1 0 spi master, f sys /64 0 1 1 spi master, f sub 100 spi master timer/event counter 0 output/2 1 0 1 spi slave 110i 2 c mode 1 1 0 not used spi control register  simctl2 the simctl2 register is also used by the i 2 c interface but has the name simar .  trf the trf bit is the transmit/receive complete flag and is set high automatically when an spi data transmis - sion is completed, but must be cleared by the applica - tion program. it can be used to generate an interrupt.  wcol the wcol bit is used to detect if a data collision has occurred. if this bit is high it means that data has been attempted to be written to the simdr register during a data transfer operation. this writing operation will be ignored if data is being transferred. the bit can be cleared by the application program. note that using the wcol bit can be disabled or enabled via configu- ration option.  csen the csen bit is used as an on/off control for the scs pin. if this bit is low then the scs pin will be disabled and placed into a floating condition. if the bit is high the scs pin will be enabled and used as a select pin. note that using the csen bit can be disabled or en - abled via configuration option.  mls this is the data shift select bit and is used to select how the data is transferred, either msb or lsb first. setting the bit high will select msb first and low for lsb first.  ckeg and ckpol these two bits are used to setup the way that the clock signal outputs and inputs data on the spi bus. these two bits must be configured before data trans - fer is executed otherwise an erroneous clock edge may be generated. the ckpol bit determines the base condition of the clock line, if the bit is high then the sck line will be low when the clock is inactive. when the ckpol bit is low then the sck line will be high when the clock is inactive. the ckeg bit deter - mines active clock edge type which depends upon the condition of ckpol .
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 57 may 21, 2012  ;  = ;   + k / >  ;  = ;   + k 6 >  %     %   %          % 4 # % 6 % 3 # % / % 2 # % , % 1 # % 0 % 0 # % 1 % , # % 2 % / # % 3 % 6 # % 4  
         %  =  %            
  f
     ;      > spi slave mode timing (ckeg=0)  ;  = ;   + k / b  ; ! ) k 6 >    ! 8 b   ! 8 k /    ! 8 k / b   ! 8 k 6  = ! "            d
  >  ;  = ;   + k 6 b  ; ! ) k 6 >  ;  = ;   + k / b  ; ! ) k / >  ;  = ;   + k 6 b  ; ! ) k / >  %   = ; ! ) k 6 >  %   = ; ! ) k / >    %   %          % 4 # % 6 % 3 # % / % 2 # % , % 1 # % 0 % 0 # % 1 % , # % 2 % / # % 3 % 6 # % 4 % 4 # % 6 % 3 # % / % 2 # % , % 1 # % 0 % 0 # % 1 % , # % 2 % / # % 3 % 6 # % 4  
         %  spi master mode timing  ;  = ;   + k / >  ;  = ;   + k 6 >  %     %   %          % 4 # % 6 % 3 # % / % 2 # % , % 1 # % 0 % 0 # % 1 % , # % 2 % / # % 3 % 6 # % 4  
         %  =  %                  - 

     n   %  k f    
 
f    k / > 8    a '           &      b 
f     ! 8 k /      ! 8 k 6 b     
    -             
              &   < spi slave mode timing (ckeg=1)
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 58 may 21, 2012    ! 8  k /  
   %   
      %    + k / p        + @    
 
        p =   ' k /  p >  8 @      %    f       %         '     f   '

    p 8 @ ! 8 %            &           &  $ $         f     f
     ! 8      +      c , a 6 e k 6 6 6 b 6 6 / b 6 / 6 b 6 / /     / 6 6     c , a 6 e k / 6 / 8 spi transfer control flowchart
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 59 may 21, 2012 ckpol ckeg sck clock signal 00 high base level active rising edge 01 high base level active falling edge 10 low base level active falling edge 11 low base level active rising edge spi communication after the spi interface is enabled by setting the simen bit high, then in the master mode, when data is written to the simdr register, transmission/reception will begin si - multaneously. when the data transfer is complete, the trf flag will be set automatically, but must be cleared using the application program. in the slave mode, when the clock signal from the master has been received, any data in the simdr register will be transmitted and any data on the sdi pin will be shifted into the simdr regis - ter. the master should output an scs signal to enable the slave device before a clock signal is provided and slave data transfers should be enabled/disabled be - fore/after an scs signal is received. the spi will continue to function even after a halt in- struction has been executed. i 2 c interface the i 2 c interface is used to communicate with external peripheral devices such as sensors, eeprom memory etc. originally developed by philips, it is a two line low speed serial interface for synchronous serial data trans- fer. the advantage of only two lines for communication, relatively simple communication protocol and the ability to accommodate multiple devices on the same bus has made it an extremely popular interface type for many applications.  i 2 c interface operation the i 2 c serial interface is a two line interface, a serial data line, sda, and serial clock line, scl. as many devices may be connected together on the same bus, their outputs are both open drain types. for this rea - son it is necessary that external pull-high resistors are connected to these outputs. note that no chip select line exists, as each device on the i 2 c bus is identified by a unique address which will be transmitted and re - ceived on the i 2 c bus. when two devices communicate with each other on the bidirectional i 2 c bus, one is known as the master device and one as the slave device. both master and slave can transmit and receive data, however, it is the master device that has overall control of the bus. for these devices, which only operates in slave mode, there are two methods of transferring data on the i 2 c bus, the slave transmit mode and the slave receive mode. there are several configuration options associated with the i 2 c interface. one of these is to enable the function which selects the sim pins rather than normal i/o pins. note that if the configuration option does not select the sim function then the simen bit in the simctl0 register will have no effect. a configuration option exists to allow a clock other than the system clock to drive the i 2 c interface. another configuration option determines the debounce time of the i 2 c inter - face. this uses the internal clock to in effect add a debounce time to the external clock to reduce the pos- sibility of glitches on the clock line causing erroneous operation. the debounce time, if selected, can be chosen to be either 1 or 2 system clocks. sim function sim function sim interface or seg pins i 2 c clock i 2 c runs without internal clock disable/enable i 2 c debounce no debounce, 1 system clock; 2 system clocks i 2 c interface configuration options  i 2 c registers there are three control registers associated with the i 2 c bus, simctl0, simctl1 and simar and one data register, simdr . the simdr register, which is shown in the above spi section, is used to store the data being transmitted and received on the i 2 c bus. before the microcontroller writes data to the i 2 c bus, the actual data to be transmitted must be placed in the simdr register. after the data is received from the i 2 c bus, the microcontroller can read it from the simdr register. any transmission or reception of data from the i 2 c bus must be made via the simdr register. note that the simar register also has the name simctl2 which is used by the spi function. bits simidle , simen and bits sim0~sim2 in register simctl0 are used by the i 2 c interface. the simctl0 register is shown in the above spi section.   $    
   f                 &              #   
  f          $ *  -      f       &               f          $ *  -      f       &       
   f         
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 60 may 21, 2012  simidle the simidle bit is used to select if the i 2 c interface continues running when the device is in the idle mode. setting the bit high allows the i 2 c interface to maintain operation when the device is in the idle mode. clearing the bit to zero disables any i 2 cop - erations when in the idle mode. this spi/i 2 c idle mode control bit is located at clkmod register bit4.  simen the simen bit is the overall on/off control for the i 2 c interface. when the simen bit is cleared to zero to disable the i 2 c interface, the sda and scl lines will be in a floating condition and the i 2 c operating cur- rent will be reduced to a minimum value. in this con- dition the pins can be used as seg functions. when the bit is high the i 2 c interface is enabled. the sim configuration option must have first enabled the sim interface for this bit to be effective. note that when the simen bit changes from low to high the contents of the i 2 c control registers will be in an unknown condition and should therefore be first initialised by the application program  sim0~sim2 these bits setup the overall operating mode of the sim function. to select the i 2 c function, bits sim2~ sim0 should be set to the value 110.  rxak the rxak flag is the receive acknowledge flag. when the rxak bit has been reset to zero it means that a correct acknowledge signal has been re - ceived at the 9th clock, after 8 bits of data have been transmitted. when in the transmit mode, the transmitter checks the rxak bit to determine if the receiver wishes to receive the next byte. the trans - mitter will therefore continue sending out data until the rxak bit is set high. when this occurs, the transmitter will release the sda line to allow the master to send a stop signal to release the bus.  srw the srw bit is the slave read/write bit. this bit de - termines whether the master device wishes to transmit or receive data from the i 2 c bus. when the transmitted address and slave address match, that is when the haas bit is set high, the device will check the srw bit to determine whether it should be in transmit mode or receive mode. if the srw bit is high, the master is requesting to read data from the bus, so the device should be in transmit mode. when the srw bit is zero, the master will write data to the bus, therefore the device should be in receive mode to read this data.  txak the txak flag is the transmit acknowledge flag. af- ter the receipt of 8-bits of data, this bit will be trans- mitted to the bus on the 9th clock. to continue receiving more data, this bit has to be reset to zero before further data is received.  htx the htx flag is the transmit/receive mode bit. this flag should be set high to set the transmit mode and low for the receive mode.  hbb the hbb flag is the i 2 c busy flag. this flag will be high when the i 2 c bus is busy which will occur when a start signal is detected. the flag will be reset to zero when the bus is free which will occur when a stop signal is detected.  hass the hass flag is the address match flag. this flag is used to determine if the slave device address is the same as the master transmit address. if the ad - dresses match then this bit will be high, if there is no match then the flag will be low.  hcf the hcf flag is the data transfer flag. this flag will be zero when data is being transferred. upon com - pletion of an 8-bit data transfer the flag will go high and an interrupt will be generated.  ,  %       
    =    %  >    &   $          
    =    $  >  
f     
    %
  
         : $            d $ $   7
  ,         %    
 +  7 %           7    
 #   
&        
   
  %          %                  %     7   $              !     # %
      $ *  -          # - 
      &      7
 d 7 7  7
 d  :  7
  +  
 % $  
d '  7
 i 2 c block diagram
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 61 may 21, 2012 i 2 c control register  simar the simar register is also used by the spi interface but has the name simctl2. the simar register is the location where the 7-bit slave address of the microcontroller is stored. bits 1~7 of the simar register define the microcontroller slave ad - dress. bit 0 is not defined. when a master device, which is connected to the i 2 c bus, sends out an address, which matches the slave address in the simar register, the microcontroller slave device will be selected. note that the simar register is the same register as simctl2 which is used by the spi interface. i 2 c bus communication communication on the i 2 c bus requires four separate steps, a start signal, a slave device address transmis - sion, a data transmission and finally a stop signal. when a start signal is placed on the i 2 c bus, all de - vices on the bus will receive this signal and be notified of the imminent arrival of data on the bus. the first seven bits of the data will be the slave address with the first bit being the msb. if the address of the microcontroller matches that of the transmitted address, the haas bit in the simctl1 register will be set and an i 2 c interrupt will be generated. after entering the interrupt service rou - tine, the microcontroller slave device must first check the condition of the haas bit to determine whether the interrupt source originates from an address match or from the completion of an 8-bit data transfer. during a data transfer, note that after the 7-bit slave address has been transmitted, the following bit, which is the 8th bit, is the read/write bit whose value will be placed in the srw bit. this bit will be checked by the microcontroller to de- termine whether to go into transmit or receive mode. be- fore any transfer of data to or from the i 2 c bus, the microcontroller must initialise the bus, the following are steps to achieve this: step 1 write the slave address of the microcontroller to the i 2 c bus address register simar. step 2 set the simen bit in the simctl0 register to 1 to en - able the i 2 c bus. step 3 set the esim bit of the interrupt control register to en - able the i 2 c bus interrupt.  start signal the start signal can only be generated by the mas - ter device connected to the i 2 c bus and not by the microcontroller , which is only a slave device. this start signal will be detected by all devices con - nected to the i 2 c bus. when detected, this indicates that the i 2 c bus is busy and therefore the hbb bit will be set. a start condition occurs when a high to low transition on the sda line takes place when the scl line remains high.  slave address the transmission of a start signal by the master will be detected by all devices on the i 2 c bus. to deter- mine which slave device the master wishes to com- municate with, the address of the slave device will be sent out immediately following the start signal. all slave devices, after receiving this 7-bit address data, will compare it with their own 7-bit slave address. if the address sent out by the master matches the internal address of the microcontroller slave device, then an internal i 2 c bus interrupt signal will be generated. the next bit following the address, which is the 8th bit, de - fines the read/write status and will be saved to the srw bit of the simctl1 register. the device will then transmit an acknowledge bit, which is a low level, as the 9th bit. the microcontroller slave device will also set the status flag haas when the addresses match. as an i 2 c bus interrupt can come from two sources, when the program enters the interrupt subroutine, the haas bit should be examined to see whether the in - terrupt source has come from a matching slave ad - dress or from the completion of a data byte transfer. when a slave address is matched, the device must be placed in either the transmit mode and then write data to the simdr register, or in the receive mode where it must implement a dummy read from the simdr regis - ter to release the scl line. % . -      $     4 8   
      b          h 6 h  ,    &
     &           6  $ 2  $ 1  $ 3  $ 6  $ 0  $ ,  $ / i 2 c slave address register  simar         
      &    $              $   !      c , a 6 e k / / 6  !      ! 8     ,  7          k p  !     %
         !   ! d   
  f           )      
       +   ! d        d  '      
   -              ,  7        )      
       i 2 c bus initialisation flow chart
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 62 may 21, 2012      d $ $  k / p d  : k /     p    k /      p @   8  @   8   : $ ; k / p @   8  8       f      %   !   @   %        f       %   !    !    
        %   !   d  :  
        %  %        '       %  +   d  : +    : $ ;  !    !   +   d  : +    : $ ; i 2 c bus isr flow chart %    / 6 /        6 6 /        66 / 6 6 / 6 / 6 / /  k       = /  
 >  $ k    &   $        = 4  
  >   k     
  = /  
 >  k    &     &
       *  -       
  = /  
 > % k %     =   
  > $ k $ ;  =  : $ ;  
  f       
    b   : $ ;  
  f      
&    /  
 >  k     = /  
 >  +       % $    $ ; $ ;     +  % $    &   $         $    % $ % $   $    % $ % $  i 2 c communication timing diagram
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 63 may 21, 2012  srw bit the srw bit in the simctl1 register defines whether the microcontroller slave device wishes to read data from the i 2 c bus or write data to the i 2 c bus. the microcontroller should examine this bit to determine if it is to be a transmitter or a receiver. if the srw bit is set to 1 then this indicates that the master wishes to read data from the i 2 c bus, therefore the microcontroller slave device must be setup to send data to the i 2 c bus as a transmitter. if the srw bit is 0 then this indicates that the master wishes to send data to the i 2 c bus, therefore the microcontroller slave device must be setup to read data from the i 2 c bus as a receiver.  acknowledge bit after the master has transmitted a calling address, any slave device on the i 2 c bus, whose own internal address matches the calling address, must generate an acknowledge signal. this acknowledge signal will inform the master that a slave device has accepted its calling address. if no acknowledge signal is received by the master then a stop signal must be transmitted by the master to end the communication. when the haas bit is high, the addresses have matched and the microcontroller slave device must check the srw bit to determine if it is to be a transmitter or a receiver. if the srw bit is high, the microcontroller slave device should be setup to be a transmitter so the htx bit in the simctl1 register should be set to 1 if the srw bit is low then the microcontroller slave device should be setup as a receiver and the htx bit in the simctl1 register should be set to 0.  data byte the transmitted data is 8-bits wide and is transmitted after the slave device has acknowledged receipt of its slave address. the order of serial bit transmission is the msb first and the lsb last. after receipt of 8-bits of data, the receiver must transmit an acknowledge sig - nal, level 0 , before it can receive the next data byte. if the transmitter does not receive an acknowledge bit signal from the receiver, then it will release the sda line and the master will send out a stop signal to re - lease control of the i 2 c bus. the corresponding data will be stored in the simdr register. if setup as a transmitter, the microcontroller slave device must first write the data to be transmitted into the simdr regis - ter. if setup as a receiver, the microcontroller slave de - vice must read the transmitted data from the simdr register.  receive acknowledge bit when the receiver wishes to continue to receive the next data byte, it must generate an acknowledge bit, known as txak, on the 9th clock. the microcontroller slave device, which is setup as a transmitter will check the rxak bit in the simctl1 register to determine if it is to send another data byte, if not then it will release the sda line and await the receipt of a stop signal from the master. peripheral clock output the peripheral clock output allows the device to supply external hardware with a clock signal synchronised to the microcontroller clock. peripheral clock operation as the peripheral clock output pin, pclk , is shared with one of the lcd segment lines, the required pin function is chosen via pcken in simctl0 register. the periph - eral clock function is controlled using the simctl0 reg - ister. the clock source for the peripheral clock output can originate from either the timer/event counter 0 di - vided by two or a divided ratio of the internal f sys clock. the pcken bit in the simctl0 register is the overall on/off control, setting the bit high enables the peripheral clock, clearing it disables it. the required division ratio of the system clock is selected using the pckpsc0 and pckpsc1 bits in the same register. if the system enters the sleep mode this will disable the peripheral clock output.  +  % $       
   %             %          -         
 data timing diagram f  @  
  # ! &         6    ,  + ;     ! )       + ;    ! )   / b  1 b    ; ! 8  ;   6  ;   /          peripheral clock block diagram
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 64 may 21, 2012 buzzer operating in a similar way to the programmable fre - quency divider, the buzzer function provides a means of producing a variable frequency output, suitable for ap - plications such as piezo-buzzer driving or other external circuits that require a precise frequency generator. the bz and bz pins form a complementary pair, and are pin-shared with i/o pins, pa0 and pa1. a configuration option is used to select from one of three buzzer options. the first option is for both pins pa0 and pa1 to be used as normal i/os, the second option is for both pins to be configured as bz and bz buzzer pins, the third option selects only the pa0 pin to be used as a bz buzzer pin with the pa1 pin retaining its normal i/o pin function. note that the bz pin is the inverse of the bz pin which to - gether generate a differential output which can supply more power to connected interfaces such as buzzers. the buzzer is driven by the internal clock source, , which then passes through a divider, the division ratio of which is selected by configuration options to provide a range of buzzer frequencies from f s /2 2 to f s /2 9 . the clock source that generates f s , which in turn controls the buzzer fre - quency, can originate from three different sources, the 32768hz oscillator, the 32k_int oscillator or the sys - tem oscillator/4, the choice of which is determined by the f s clock source configuration option. note that the buzzer frequency is controlled by configuration options, which select both the source clock for the internal clock f s and the internal division ratio. there are no internal registers associated with the buzzer frequency. if the configuration options have selected both pins pa0 and pa1 to function as a bz and bz complementary pair of buzzer outputs, then for correct buzzer operation it is essential that both pins must be setup as outputs by set- ting bits pac0 and pac1 of the pac port control register to zero. the pa0 data bit in the pa data register must also be set high to enable the buzzer outputs, if set low, both pins pa0 and pa1 will remain low. in this way the single bit pa0 of the pa register can be used as an on/off control for both the bz and bz buzzer pin outputs. note that the pa1 data bit in the pa register has no control over the bz buzzer pin pa1. f         f
    
  
 f  @  # 1 0 , 4 3  d l 0 , ; g  8   f
    
   
 %
&
      , , i , 5 f  7 9 7 9 buzzer function % . -        $    8   
      b          o 6 h    #  ,   #  f       / a       6 a  
      ;    *         
        *        / a    *                6 a    *           
               #    &        *            
        -      6           *       f  @  f  @  # 1 f  @  #  
  # ! &          6    ,  ;   / 6 6 / /  ;   6 6 / 6 /    ! 8  4    /    6    ,  ; ! 8  ;   /  ;   6 peripheral clock output control  simctl0
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 65 may 21, 2012 pa0/pa1 pin function control pac register pac0 pac register pac1 pa data register pa0 pa data register pa1 output function 001x pa0=bz pa1=bz 000x pa0=0 pa1=0 011x pa0=bz pa1=input line 010x pa0=0 pa1=input line 10xd pa0=input line pa1=d 11xx pa0=input line pa0=input line x  stands for don
t care d stands for data 0 or 1 if configuration options have selected that only the pa0 pin is to function as a bz buzzer pin, then the pa1 pin can be used as a normal i/o pin. for the pa0 pin to func - tion as a bz buzzer pin, pa0 must be setup as an output by setting bit pac0 of the pac port control register to zero. the pa0 data bit in the pa data register must also be set high to enable the buzzer output, if set low pin pa0 will remain low. in this way the pa0 bit can be used as an on/off control for the bz buzzer pin pa0. if the pac0 bit of the pac port control register is set high, then pin pa0 can still be used as an input even though the configuration option has configured it as a bz buzzer output. note that no matter what configuration option is chosen for the buzzer, if the port control register has setup the pin to function as an input, then this will override the con - figuration option selection and force the pin to always behave as an input pin. this arrangement enables the pin to be used as both a buzzer pin and as an input pin, so regardless of the configuration option chosen; the ac- tual function of the pin can be changed dynamically by the application program by programming the appropri- ate port control register bit.          *        $ 6  %    7 9            $ 6 7 9            $ /  $ /  %    buzzer output pin control note: the above drawing shows the situation where both pins pa0 and pa1 are selected by configuration option to be bz and bz buzzer pin outputs. the port control register of both pins must have already been setup as out - put. the data setup on pin pa1 has no effect on the buzzer outputs.
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 66 may 21, 2012 interrupts interrupts are an important part of any microcontroller system. when an external event or an internal function such as a timer/event counter or an a/d converter re - quires microcontroller attention, their corresponding in - terrupt will enforce a temporary suspension of the main program allowing the microcontroller to direct attention to their respective needs. the device contains several external interrupt and internal interrupts functions. the external interrupts are controlled by the action of the ex - ternal int0, int1 and pint pins, while the internal inter - rupts are controlled by the timer/event counter overflows, the time base interrupt, the rtc interrupt, the spi/i 2 c interrupt and the the a/d converter interrupt. interrupt registers overall interrupt control, which means interrupt enabling and request flag setting, is controlled by the intc0, intc1, and mfic/mfic0/mfic1 registers, which are lo - cated in the data memory. by controlling the appropriate enable bits in these registers each individual interrupt can be enabled or disabled. also when an interrupt oc - curs, the corresponding request flag will be set by the microcontroller . the global enable flag if cleared to zero will disable all interrupts. interrupt operation a timer/event counter overflow, time base, rtc over- flow, spi/i 2 c data transfer complete, an end of a/d con- version or the external interrupt line being triggered will all generate an interrupt request by setting their corre- sponding request flag. when this happens and if their appropriate interrupt enable bit is set, the program counter, which stores the address of the next instruction to be executed, will be transferred onto the stack. the program counter will then be loaded with a new ad - dress which will be the value of the corresponding inter - rupt vector. the microcontroller will then fetch its next instruction from this interrupt vector. the instruction at this vector will usually be a jmp statement which will jump to another section of program which is known as the interrupt service routine. here is located the code to control the appropriate interrupt. the interrupt service routine must be terminated with a reti statement, which retrieves the original program counter address from the stack and allows the microcontroller to continue with normal execution at the point where the interrupt occurred. the various interrupt enable bits, together with their as - sociated request flags, are shown in the accompanying diagram with their order of priority. once an interrupt subroutine is serviced, all the other in - terrupts will be blocked, as the emi bit will be cleared au - tomatically. this will prevent any further interrupt nesting from occurring. however, if other interrupt requests oc - cur during this interval, although the interrupt will not be immediately serviced, the request flag will still be re - corded. if an interrupt requires immediate servicing while the program is already in another interrupt service routine, the emi bit should be set after entering the rou - tine, to allow interrupt nesting. if the stack is full, the in - terrupt request will not be acknowledged, even if the related interrupt is enabled, until the stack pointer is decremented. if immediate service is desired, the stack must be prevented from becoming full. interrupt priority interrupts, occurring in the interval between the rising edges of two consecutive t2 pulses, will be serviced on the latter of the two t2 pulses, if the corresponding inter - rupts are enabled. in case of simultaneous requests, the following table shows the priority that is applied. interrupt source priority vector external interrupt 0 1 04h external interrupt 1 2 08h timer/event counter 0 overflow 3 0ch timer/event counter 1 overflow 4 10h spi/i2c interrupt 5 14h multi-function interrupt 6 18h the a/d converter interrupt, real time clock interrupt, time base interrupt and external peripheral interrupt all share the same interrupt vector which is 18h. each of these interrupts have their own own individual interrupt flag but also share the same mff interrupt flag. the mff flag will be cleared by hardware once the multi-function interrupt is serviced, however the individ- ual interrupts that have triggered the multi-function inter- rupt need to be cleared by the application program. external interrupt for an external interrupt to occur, the global interrupt enable bit, emi, and external interrupt enable bits, eei0 and eei1, must first be set. additionally the correct interrupt edge type must be selected using the intedge register to enable the external interrupt function and to choose the trigger edge type. an actual external interrupt will take place when the external interrupt request flag, eif0 or eif1, is set, a situation that will occur when a transition, whose type is chosen by the edge select bit, appears on the int0 or int1 pin. the external interrupt pins are pin-shared with the i/o pins pd4 and pd5 and can only be configured as external interrupt pins if their corresponding external interrupt enable bit in the intc0 register has been set. the pin must also be setup as an input by setting the corresponding pdc.4 and pdc.5 bits in the port control register. when the interrupt is enabled, the stack is not full and the correct transition type appears on the external interrupt pin, a subroutine call to the external
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 67 may 21, 2012 . 3       $         
                   / a              6 a         
     ! "      
       6       / a       6 a  
     ! "      
       /       / a       6 a  
     
  # ! &          6 
            / a       6 a  
     ! "      
       6    (      f    / a   
&  6 a 
 
&  ! "      
       /    (      f    / a   
&  6 a 
 
&  
  # ! &          6 
         (      f    / a   
&  6 a 
 
&  8   
      b          h 6 h  4  6 ! !  / ! !  6 !   !  ' 6!  ' / !  6   6 ' interrupt control register  intc0 . 3       $    
  # ! &          / 
            / a       6 a  
        #  , 
            / a       6 a  
        
 f  
 
            / a       6 a  
     8   
      b          h 6 h 
  # ! &          / 
         (      f    / a   
&  6 a 
 
&     #  , 
         (      f    / a   
&  6 a 
 
&     
 f  
 
         (      f    / a   
&  6 a 
 
&  8   
      b          h 6 h  4  6 !  '  !    !  /   / '   '  ' ' interrupt control register  intc1
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 68 may 21, 2012 - .  # - .      $    $ # %   &      
            / a       6 a  
          
    * 
            / a       6 a  
     
  7    
            / a       6 a  
     ! "        
     
            / a       6 a  
     $ # %   &      
         (      f    / a   
&  6 a 
 
&       
    * 
         (      f    / a   
&  6 a 
 
&  
  7    
         (      f    / a   
&  6 a 
 
&  ! "        
     
         (      f    / a   
&  6 a 
 
&   4  6 !  7  !    ! $ %  $ % '  '  7 ' !    ! ' interrupt control register  mfic/mfic0 - .      $    
  # ! &          , 
            / a       6 a  
     
  # ! &          0 
            / a       6 a  
     8   
      b          h 6 h 
  # ! &          , 
         (      f    / a   
&  6 a 
 
&  
  # ! &          0 
         (      f    / a   
&  6 a 
 
&  8   
      b          h 6 h  4  6 !  ,   , ' !  0   0 ' interrupt control register  mfic1
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 69 may 21, 2012 $     
                        "   f    $ % ' b   7 ' b    '      , '                            f  -    $     
     %
                  !               
 
  d
            
 ! "                (      '     !  ' / ! !  6 
  # ! &          6           (      '      6 ' ! !  / !  6  
  # ! &          /           (      '      / ' !  /     #  ,           (      '        ' !    ! "                (      '     !  ' 6    
 f  
           (      '      ' ' !  '  !   +  - 
  7              (      '      7 ' ! $ %       
    *           (      '       ' !    $ # %   &                (      '     $ % ' !  7  !   ! "         
               (      '      ! ' 
  # ! &          ,           (      '      , ' !  ,  
  # ! &          0           (      '      0 ' !  0  interrupt structure interrupt vector at location 04h or 08h, will take place. when the interrupt is serviced, the external interrupt request flags, eif0 or eif1, will be automatically reset and the emi bit will be automatically cleared to disable other interrupts. note that any pull-high resistor selections on this pin will remain valid even if the pin is used as an external interrupt input. the intedge register is used to select the type of active edge that will trigger the external interrupt. a choice of ei - ther rising and falling edge types can be chosen along with an option to allow both edge types to trigger an exter - nal interrupt. note that the intedge register can also be used to disable the external interrupt function. the external interrupt pins are connected to an internal filter to reduce the possibility of unwanted external inter - rupts due to adverse noise or spikes on the external in - terrupt input signal. as this internal filter circuit will consume a limited amount of power, a configuration op - tion is provided to switch off the filter function, an option which may be beneficial in power sensitive applications, but in which the integrity of the input signal is high. care must be taken when using the filter on/off configuration option as it will be applied not only to both the external interrupt pins but also to the timer/event counter exter - nal input pins. individual external interrupt or timer/event counter pins cannot be selected to have a filter on/off function. '
      #  f f  f
    
   
  8  / '
     8  6 '
    ! "        8  < 6 ! "        8  < / -  &
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 70 may 21, 2012 external peripheral interrupt the external peripheral interrupt operates in a similar way to the external interrupt and is contained within the multi-function interrupt. for an external peripheral interrupt to occur, the global interrupt enable bit, emi, external peripheral interrupt enable bit, epi, and multi-function interrupt enable bit, emfi, must first be set. an actual external peripheral in - terrupt will take place when the external interrupt re - quest flag, pef, is set, a situation that will occur when a negative transition, appears on the pint pin. the exter- nal peripheral interrupt pin is pin-shared with one of the segment pins, and is configured as a peripheral interrupt pin via a configuration option. when the interrupt is en- abled, the stack is not full and a negative transition type appears on the external peripheral interrupt pin, a sub- routine call to the multi-function interrupt vector at location18h, will take place. when the external periph- eral interrupt is serviced, the emi bit will be cleared to disable other interrupts, however only the mff interrupt request flag will be reset. as the pef flag will not be au - tomatically reset, it has to be cleared by the application program. timer/event counter interrupt for a timer/event counter 0 or timer/event counter 1 interrupt to occur, the global interrupt enable bit, emi, and the corresponding timer interrupt enable bit, et0i or et1i must first be set. an actual timer/event counter in - terrupt will take place when the timer/event counter re - quest flag, t0f or t1f is set, a situation that will occur when the timer/event counter overflows. when the in - terrupt is enabled, the stack is not full and a timer/event counter overflow occurs, a subroutine call to the timer interrupt vector at location 0ch or 10c, will take place. when the interrupt is serviced, the timer interrupt re - quest flag, t0f or t1f, will be automatically reset and the emi bit will be automatically cleared to disable other interrupts. timer event counter 0 and timer/event counter 1 have their own individual interrupt vectors, however the inter - rupt vector for timer/event counter 2 or timer/event counter 3 is contained within the multi-function interrupt. for a timer/event counter 2 or a timer/event counter 3 interrupt to occur, the global interrupt enable bit, emi, timer/event counter 2 or timer/event counter 3 inter - rupt enable bit, et2i or et3i, and multi-function interrupt enable bit, emfi, must first be set. an actual interrupt will take place when the timer/event counter 2 or timer/event counter 3 request flag, t2f or t3f, is set, a situation that will occur when the timer/event counter 2 or timer/event counter 3 overflows. when the interrupt is enabled, the stack is not full and the timer/event counter 2 or timer/event counter 3 overflows, a subrou- tine call to the multi-function interrupt vector at location 18h, will take place. when the timer/event 2 or timer/event counter 3 interrupt is serviced, the emi bit will be cleared to disable other interrupts, however only the mff interrupt request flag will be reset. as the t2f or t3f flag will not be automatically reset, it has to be cleared by the application program. a/d interrupt the a/d interrupt is contained within the multi-function interrupt. for an a/d interrupt to be generated, the global interrupt enable bit, emi, a/d interrupt enable bit, eadi, and multi-function interrupt enable bit, emfi, must first be set. an actual a/d interrupt will take place when the a/d interrupt request flag, adf, is set, a situation that will oc - cur when the a/d conversion process has finished. when the interrupt is enabled, the stack is not full and the a/d conversion process has ended, a subroutine call to the multi-function interrupt vector at location18h, will take place. when the a/d interrupt is serviced, the emi bit will be cleared to disable other interrupts, how - ever only the mff interrupt request flag will be reset. as the adf flag will not be automatically reset, it has to be cleared by the application program. . 3  2 0 9 2    $     8  6  !           8  6  /         8  6  6   8  /  !           8  /  /        8  /  6 8   
      b          h 6 h  6  8  /  6  8  6  /  8  6  6  4  8  /  / 6 6 / / 6 / 6 / 
     

        
    f   
        
               
    6 6 / / 6 / 6 / 
     

        
    f   
        
               
    interrupt active edge register  intedge
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 71 may 21, 2012 spi/i 2 c interface interrupt for an spi/i 2 c interrupt to occur, the global interrupt en - able bit, emi, and the corresponding interrupt enable bit, esim must be first set. an actual spi/i 2 c interrupt will take place when the spl/i 2 c request flag, simf, is set, a situation that will occur when a byte of data has been transmitted or received by the spi/i 2 c interface or when an i 2 c address match occurs. when the interrupt is en - abled, the stack is not full and a byte of data has been transmitted or received by the spi/i 2 c interface or an i 2 c address match occurs, a subroutine call to the spi/i 2 c interrupt vector at location 14h, will take place. when the interrupt is serviced, the spi/i 2 c request flag, simf will be automatically reset and the emi bit will be auto - matically cleared to disable other interrupts. multi-function interrupt an additional interrupt known as the multi-function inter - rupt is provided. unlike the other interrupts, this interrupt has no independent source, but rather is formed from four or five other existing interrupt sources, namely the a/d converter interrupt, time base interrupt, real time clock interrupt, external peripheral interrupt and the timer 2 overflow interrupt. for a multi-function interrupt to occur, the global interrupt enable bit, emi, and the multi-function interrupt enable bit, emfi, must first be set. an actual multi-function inter- rupt will take place when the multi-function interrupt re- quest flag, mff, is set. this will occur when either a time base overflow, a real time clock overflow, an a/d con- version completion, an external peripheral interrupt or timer 2 overflow interrupt is generated. when the inter- rupt is enabled and the stack is not full, and either one of the interrupts contained within the multi-function interrupt occurs, a subroutine call to the multi-function interrupt vector at location 018h will take place. when the interrupt is serviced, the multi-function request flag, mff, will be automatically reset and the emi bit will be automatically cleared to disable other interrupts. however, it must be noted that the request flags from the original source of the multi-function interrupt, namely the time-base interrupt, real time clock interrupt, a/d converter interrupt, exter - nal peripheral interrupt or timer 2 overflow interrupt will not be automatically reset and must be manually reset by the application program. real time clock interrupt the real time clock interrupt is contained within the multi-function interrupt. for a real time clock interrupt to be generated, the global interrupt enable bit, emi , real time clock inter - rupt enable bit, erti, and multi-function interrupt enable bit, emfi, must first be set. an actual real time clock interrupt will take place when the real time clock re - quest flag, rtf, is set, a situation that will occur when the real time clock overflows. when the interrupt is en - abled, the stack is not full and the real time clock over - flows, a subroutine call to the multi-function interrupt vector at location18h, will take place. when the real time clock interrupt is serviced, the emi bit will be cleared to disable other interrupts, however only the mff interrupt request flag will be reset. as the rtf flag will not be automatically reset, it has to be cleared by the application program. similar in operation to the time base interrupt, the pur - pose of the rtc interrupt is also to provide an interrupt signal at fixed time periods. the rtc interrupt clock source originates from the internal clock source f s . this f s input clock first passes through a divider, the division ratio of which is selected by programming the appropri - ate bits in the rtcc register to obtain longer rtc inter - rupt periods whose value ranges from 2 8 /f s ~2 15 /f s . the clock source that generates f s , which in turn controls the rtc interrupt period, can originate from three different sources, the 32768hz oscillator, 32k_int oscillator or the system oscillator/4, the choice of which is determine by the f s clock source configuration option. note that the rtc interrupt period is controlled by both configuration options and an internal register rtcc. a configuration option selects the source clock for the in - ternal clock f s , and the rtcc register bits rt2, rt1 and rt0 select the division ratio. note that the actual divi - sion ratio can be programmed from 2 8 to 2 15 . f         f
    
  
 f  @  # 1 0 , 4 3  d l 0 , ; g  8  %
&
      ,  i , / 2            
    f            , / , # f  i , / 2 # f    ,   /   6 rtc interrupt
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 72 may 21, 2012 time base interrupt the time base interrupt is contained within the multi-function interrupt. for a time base interrupt to be generated, the global in - terrupt enable bit, emi,time base interrupt enable bit, etbi, and multi-function interrupt enable bit, emfi, must first be set. an actual time base interrupt will take place when the time base interrupt request flag, tbf, is set, a situation that will occur when the time base over- flows. when the interrupt is enabled, the stack is not full and the time base overflows, a subroutine call to the multi-function interrupt vector at location18h, will take place. when the time base interrupt is serviced, the emi bit will be cleared to disable other interrupts, how- ever only the mff interrupt request flag will be reset. as the tbf flag will not be automatically reset, it has to be cleared by the application program. the purpose of the time base function is to provide an interrupt signal at fixed time periods. the time base in - terrupt clock source originates from the time base inter - rupt clock source originates from the internal clock source f s . this f s input clock first passes through a di - vider, the division ratio of which is selected by configura - tion options to provide longer time base interrupt periods. the time base interrupt time-out period ranges from 2 12 /f s ~2 15 /f s . the clock source that generates f s , which in turn controls the time base interrupt period, can originate from three different sources, the 32768hz oscillator, the 32k_int internal oscillator or the system oscillator/4, the choice of which is determine by the f s clock source configuration option. essentially operating as a programmable timer, when the time base overflows it will set a time base interrupt flag which will in turn generate an interrupt request via the multi-function interrupt vector. programming considerations by disabling the interrupt enable bits, a requested inter- rupt can be prevented from being serviced, however, once an interrupt request flag is set, it will remain in this condition in the intc0, intc1 and mfic registers until the corresponding interrupt is serviced or until the re- quest flag is cleared by the application program. it is recommended that programs do not use the call subroutine instruction within the interrupt subroutine. interrupts often occur in an unpredictable manner or need to be serviced immediately in some applications. if only one stack is left and the interrupt is not well con - trolled, the original control sequence will be damaged once a  call subroutine is executed in the interrupt subroutine. all of these interrupts have the capability of waking up the processor when in the power down mode. only the program counter is pushed onto the stack. if the contents of the status or other registers are altered by the interrupt service program, which may corrupt the desired control sequence, then the contents should be saved in advance. f         f
    
  
 f  @  # 1 0 , 4 3  d l 0 , ; g  8   f
    
   
 %
&
      , / , i , / 2 f  
  7            , / , # f  i , / 2 # f  time base interrupt        $     4  6 + . %  j   + . %   ,   /   6   , 6 6 6 6 / / / /   / 6 6 / / 6 6 / /   6 6 / 6 / 6 / 6 /   
   ,  # f   , 5 # f   , / 6 # f   , / / # f   , / , # f   , / 0 # f   , / 1 # f   , / 2 # f               
  +  -  .        %             / a       6 a  
         
       j 
*       / a  
     6 a       +  -  .        %             / a    -  &               6 a       &       8   
      b          h 6 h  real time clock control register  rtcc
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 73 may 21, 2012 reset and initialisation a reset function is a fundamental part of any microcontroller ensuring that the device can be set to some predetermined condition irrespective of outside parameters. the most important reset condition is after power is first applied to the microcontroller . in this case, internal circuitry will ensure that the microcontroller ,af - ter a short delay, will be in a well defined state and ready to execute the first program instruction. after this power-on reset, certain important internal registers will be set to defined states before the program com - mences. one of these registers is the program counter, which will be reset to zero forcing the microcontroller to begin program execution from the lowest program memory address. in addition to the power-on reset, situations may arise where it is necessary to forcefully apply a reset condition when the microcontroller is running. one example of this is where after power has been applied and the microcontroller is already running, the res line is force - fully pulled low. in such a case, known as a normal oper - ation reset, some of the microcontroller registers remain unchanged allowing the microcontroller to proceed with normal operation after the reset line is allowed to return high. another type of reset is when the watchdog timer overflows and resets the microcontroller . all types of re- set operations result in different register conditions be- ing setup. another reset exists in the form of a low voltage reset, lvr, where a full reset, similar to the res reset is imple- mented in situations where the power supply voltage falls below a certain threshold. reset functions there are five ways in which a microcontroller reset can occur, through events occurring both internally and ex - ternally:  power-on reset the most fundamental and unavoidable reset is the one that occurs after power is first applied to the microcontroller . as well as ensuring that the program memory begins execution from the first memory ad - dress, a power-on reset also ensures that certain other registers are preset to known conditions. all the i/o port and port control registers will power up in a high condition ensuring that all pins will be first set to inputs. although the microcontroller has an internal rc reset function, if the vdd power supply rise time is not fast enough or does not stabilise quickly at power-on, the internal reset function may be incapable of providing proper reset operation. for this reason it is recom - mended that an external rc network is connected to the res pin, whose additional time delay will ensure that the res pin remains low for an extended period to allow the power supply to stabilise. during this time delay, normal operation of the microcontroller will be inhibited. after the res line reaches a certain voltage value, the reset delay time t rstd is invoked to provide an extra delay time after which the microcontroller will begin normal operation. the abbreviation sst in the figures stands for system start-up timer. for most applications a resistor connected between vdd and the res pin and a capacitor connected be - tween vss and the res pin will provide a suitable ex - ternal reset circuit. any wiring connected to the res pin should be kept as short as possible to minimise any stray noise interference. for applications that operate within an environment where more noise is present the enhanced reset cir - cuit shown is recommended. more information regarding external reset circuits is located in application note ha0075e on the holtek website.  res pin reset this type of reset occurs when the microcontroller is already running and the res pin is forcefully pulled low by external hardware such as an external switch. in this case as in the case of other reset, the program counter will reset to zero and program execution initi - ated from this point.  !      
     
      6 < 5  . % % 6 < 1  . % %     % res reset timing chart  !  . % %     
     
      6 < 5  . % %     % power-on reset timing chart  !  #  $ 4 6 < / i /  ' / 6 *  i / 6 6 *  . % % .   6 < 6 /  ' m m . % % / 8 1 / 1  m 0 6 6  m note: * it is recommended that this component is added for added esd protection ** it is recommended that this component is added in environments where power line noise is significant external res circuit
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 74 may 21, 2012  low voltage reset  lvr the microcontroller contains a low voltage reset circuit in order to monitor the supply voltage of the device, which is selected via a configuration option. if the supply voltage of the device drops to within a range of 0.9v~v lvr such as might occur when changing the bat - tery, the lvr will automatically reset the device inter - nally. the lvr includes the following specifications: for a valid lvr signal, a low voltage, i.e., a voltage in the range between 0.9v~v lvr must exist for greater than the value t lvr specified in the a.c. characteristics. if the low voltage state does not exceed 1ms, the lvr will ignore it and will not perform a reset function. one of a range of specified voltage values for v lvr can be selected using configuration options. the v lvr value will be selected as a pair in conjunction with a low voltage detect value.  watchdog time-out reset during normal operation the watchdog time-out reset during normal opera - tion is the same as a hardware res pin reset except that the watchdog time-out flag to will be set to 1.  watchdog time-out reset during power down the watchdog time-out reset during power down is a little different from other kinds of reset. most of the conditions remain unchanged except that the pro - gram counter and the stack pointer will be cleared to 0 and the to flag will be set to 1 . refer to the a.c. characteristics for t sst details. reset initial conditions the different types of reset described affect the reset flags in different ways. these flags, known as pdf and to are located in the status register and are controlled by various microcontroller operations, such as the power down function or watchdog timer. the reset flags are shown in the table: to pdf reset conditions 0 0 res reset during power-on u u res or lvr reset during normal operation 1 u wdt time-out reset during normal operation 1 1 wdt time-out reset during power down note: u stands for unchanged the following table indicates the way in which the vari - ous components of the microcontroller are affected after a power-on reset occurs. item condition after reset program counter reset to zero interrupts all interrupts will be disabled wdt clear after reset, wdt begins counting timer/event counter timer counter will be turned off prescaler the timer counter prescaler will be cleared input/output ports i/o ports will be setup as inputs stack pointer stack pointer will point to the top of the stack + .      
     
          % low voltage reset timing chart  %   
         
     
          % wdt time-out reset during normal operation timing chart  %   
         
         wdt time-out reset during power down timing chart
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 75 may 21, 2012 the different kinds of resets all affect the internal registers of the microcontroller in different ways. to ensure reliable continuation of normal program execution after a reset occurs, it is important to know what condition the microcontroller is in after a particular reset occurs. the following table describes how each type of reset affects each of the microcontroller internal registers. note that where more than one package type exists the table will reflect the situation for the larger package type. register reset (power-on) res reset (normal operation) wdt time-out (normal operation) wdt time-out (halt) mp0 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu mp1 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu bp 000 0000 000  0000 000  0000 uuu  uuuu acc xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu pcl 0000 0000 0000 0000 0000 0000 0000 0000 tblp xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu tblh xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu rtcc  00 0111  00 0111  00 0111  uu uuuu status  00 xxxx  uu uuuu  1u uuuu  11 uuuu intc0 0000 0000 0000 0000 0000 0000 uuuu uuuu tmr0 xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu tmr0c 00 0 1000 00  0 1000 00  0 1000 uu  u uuuu tmr1h xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu tmr1l xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu tmr1c 0000 1   0000 1   0000 1   uuuu u   tmr2 xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu tmr2c 00 0 1000 00  0 1000 00  0 1000 uu  u uuuu tmr3 xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu tmr3c 00 0 1000 00  0 1000 00  0 1000 uu  u uuuu pa 1111 1111 1111 1111 1111 1111 uuuu uuuu pac 1111 1111 1111 1111 1111 1111 uuuu uuuu pb 1111 1111 1111 1111 1111 1111 uuuu uuuu pbc 1111 1111 1111 1111 1111 1111 uuuu uuuu pc 1111 1111 1111 1111 1111 1111 uuuu uuuu pcc 1111 1111 1111 1111 1111 1111 uuuu uuuu pd 1111 1111 1111 1111 1111 1111 uuuu uuuu pdc 1111 1111 1111 1111 1111 1111 uuuu uuuu pwm0l 0000   0 0000   0 0000   0 uuuu   u pwm0h 0000 0000 0000 0000 0000 0000 uuuu uuuu pwm1l 0000   0 0000   0 0000   0 uuuu   u pwm1h 0000 0000 0000 0000 0000 0000 uuuu uuuu intc1  000 00  000 00  000 00  uuu uu pwm2l 0000   0 0000   0 0000   0 uuuu   u pwm2h 0000 0000 0000 0000 0000 0000 uuuu uuuu pwm3l 0000   0 0000   0 0000   0 uuuu   u
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 76 may 21, 2012 register reset (power-on) res reset (normal operation) wdt time-out (normal operation) wdt time-out (halt) pwm3h 0000 0000 0000 0000 0000 0000 uuuu uuuu adrl xxxx  xxxx  xxxx  uuuu  adrh xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu adcr 0100 0000 0100 0000 0100 0000 uuuu uuuu acsr 10   000 10   000 10   000 uu   uuu clkmod 0000 0x11 0000 0x11 0000 0x11 uuuu uuuu pawu 0000 0000 0000 0000 0000 0000 uuuu uuuu papu 0000 0000 0000 0000 0000 0000 uuuu uuuu pbpu 0000 0000 0000 0000 0000 0000 uuuu uuuu pcpu 0000 0000 0000 0000 0000 0000 uuuu uuuu pdpu 0000 0000 0000 0000 0000 0000 uuuu uuuu intedge  0000  0000  0000  uuuu lcdctrl 0000 0000 0000 0000 0000 0000 uuuu uuuu lcdout1   00   00   00   uu lcdout2 0000 0000 0000 0000 0000 0000 uuuu uuuu ledctrl  000 0000  000 0000  000 0000  uuu uuuu misc 0000 1010 0000 1010 0000 1010 uuuu uuuu mfic/mfic0 0000 0000 0000 0000 0000 0000 uuuu uuuu mfic1 00 00 00 00 00 00 uu uu simctl0 1110 0000 1110 0000 1110 0000 uuuu uuuu simctl1 1000 00  1 1000 00  1 1000 00  1 uuuu uu  u simdr xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu simar/simctl2 0000 0000 0000 0000 0000 0000 uuuu uuuu note: u stands for unchanged x stands for unknown  stands for unimplemented
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 77 may 21, 2012 oscillator various oscillator options offer the user a wide range of functions according to their various application require - ments. three types of system clocks can be selected while various clock source options are provided for max - imum flexibility. all oscillator options are selected through the configuration options. system clock configurations there are three methods of generating the system clock, two high oscillators and an externally supplied clock. the two high oscillators are the external crystal/ceramic oscil - lator and the external rc network. selecting whether the low frequency or high oscillator is used as the system os - cillator is implemented using the hlclk bit in the clkmod register. the source clock for the high oscillator is chosen via configuration option. the frequency of the slow clock is also determined using the slowc0~slowc2 bits in the clkmod register. system crystal/ceramic oscillator after selecting the external crystal configuration option, the simple connection of a crystal across osc1 and osc2, is normally all that is required to create the nec - essary phase shift and feedback for oscillation, without requiring external capacitors. however, for some crystal types and frequencies, to ensure oscillation, it may be necessary to add two small value capacitors, c1 and c2. using a ceramic resonator will usually require two small value capacitors, c1 and c2, to be connected as shown for oscillation to occur. the values of c1 and c2 should be selected in consultation with the crystal or resonator manufacturer
s specification. in most applica- tions, resistor r p1 is not required, however for those ap- plications where the lvr function is not used, r p1 may be necessary to ensure the oscillator stops running when vdd falls below its operating range. the internal oscillator circuit contains a filter circuit to reduce the possibility of erratic operation due to noise on the oscil - lator pins. an additional configuration option must be setup to configure the device according to whether the oscillator frequency is high, defined as equal to or above 1mhz, or low, which is defined as below 1 mhz. more information regarding oscillator applications is lo - cated on the holtek website. crystal oscillator c1 and c2 values crystal frequency c1 c2 12mhz  8mhz  4mhz  1mhz  455khz (see note 2) 10pf 10pf note: 1. c1 and c2 values are for guidance only. 2. xtal mode configuration option: 455khz. 3. r p1 =5m ~10m is recommended. crystal recommended capacitor values external system rc oscillator after selecting the correct configuration option, using the external system rc oscillator requires that a resis - tor, with a value between 47k and 1.5m ,iscon - nected between osc1 and vdd, and a 470pf capacitor is connected to ground. although this is a cost effective oscillator configuration, the oscillation frequency can vary with vdd, temperature and process variations and is therefore not suitable for applications where timing is critical or where accurate oscillator frequencies are re- quired. for the value of the external resistor r osc refer to the appendix section for typical rc oscillator vs. temperature and vdd characteristics graphics. note that an internal capacitor together with the external resistor, r osc , are the components which determine the frequency of the oscillator. the external capacitor shown on the diagram does not influence the frequency of oscillation. this external capacitor should be added to improve oscillator stability if the open-drain osc2 out - put is utilised in the application circuit. the internal oscil - lator circuit contains a filter circuit to reduce the possibility of erratic operation due to noise on the oscil - lator pins. internal 32k_int oscillator when microcontrollers enter a power down condition, their internal clocks are normally switched off to stop microcontroller activity and to conserve power. how - ever, in many microcontroller applications it may be nec - essary to keep some internal functions operational,   ,   / , /   / crystal/ceramic oscillator   /   , f  @  # 1  8        %  
1 4 6 ' . % %    rc oscillator
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 78 may 21, 2012 such as timers, even when the microcontroller is in the power-down mode. to do this, the device has a 32k_int oscillator, which is a fully integrated free run - ning rc oscillator with a typical period of 31.2  sat5v, requiring no external components. it is selected via con - figuration option. when the device enters the power down mode, the system clock will stop running, how - ever the 32k_int oscillator will continue to run if se - lected to keep various internal functions operational. external 32768hz oscillator with a function similar to the internal 32k-int 32khz os - cillator, that is to keep some device functions opera - tional during power down, this device also has an external 32768hz oscillator. this oscillator also remains active at all times, even when the microcontroller is in the power-down mode. this clock source has a fixed frequency of 32768hz and requires a 32768hz crystal to be connected between pins osc3 and osc4. the external resistor and capacitor components con- nected to the 32768hz crystal are not necessary to pro- vide oscillation. for applications where precise frequencies are essential, these components may be required to provide frequency compensation due to dif- ferent crystal manufacturing tolerances. a configuration option selects whether the external 32768hz oscillator or the internal 32k_int oscillator is selected. during power-up there is a time delay associated with the 32768hz oscillator waiting for it to start-up. to mini - mise this time delay, bit 4 of the rtcc register, known as the qosc bit, is provided to have a quick start-up function. during a power-up condition, this bit will be cleared to zero which will initiate the 32768hz oscillator quick start-up function. however, as there is additional power consumption associated with this quick start-up function, to reduce power consumption after start-up takes place, it is recommended that the application pro - gram should set the qosc bit high for about 2 seconds after power-on. it should be noted that, no matter what condition the qosc bit is set to, the 32768hz oscillator will always function normally, only there is more power consumption associated with the quick start-up function. 32768hz oscillator c1 and c2 values crystal frequency c3 c4 32768hz 8pf 10pf note: 1. c3 and c4 values are for guidance only. 2. r p2 =5m~10m is recommended. 32768 hz crystal recommended capacitor values external oscillator the system clock can also be supplied by an externally supplied clock giving users a method of synchronising their external hardware to the microcontroller operation. this is selected using a configuration option and supply - ing the clock on pin osc1. pin osc2 should be left floating if the external oscillator is used. the internal os - cillator circuit contains a filter circuit to reduce the possi - bility of erratic operation due to noise on the oscillator pin, however as the filter circuit consumes a certain amount of power, a oscillator configuration option exists to turn this filter off. not using the internal filter should be considered in power sensitive applications and where the externally supplied clock is of a high integrity and supplied by a low impedance source. system operating modes the devices have the ability to operate in several differ- ent modes. this range of operating modes, known as normal mode, slow mode, idle mode and sleep mode, allow the devices to run using a wide range of different slow and fast clock sources. the devices also possess the ability to dynamically switch between different clocks and operating modes. with this choice of operating functions users are provided with the flexibility to ensure they obtain optimal performance from the device ac - cording to their application specific requirements. clock sources in discussing the system clocks for the devices, they can be seen as having a dual clock mode. these dual clocks are what are known as a high oscillator and the other as a divided frequency from high oscillator. the high oscillator and low frequency are the system clock sources and can be selected dynamically using the hlclk bit in the clkmod register. the high oscillator has the internal name f m whose source is selected using a configuration option from a choice of either an external crystal/resonator, external rc oscillator or external clock source. the low frequency clock source, is further modified by the slowc0~slowc2 bits in the clkmod register to provide the low frequency clock source f slow .   1   0 1 0   , 0 , 4 3  d l 0 , 4 3  d l external 32768hz oscillator       0 , ; g  8  f  0 , ; internal 32k_int oscillator
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 79 may 21, 2012 an additional sub internal clock, with the internal name f sub , is a 32khz clock source which can be sourced from either the internal 32k_int oscillator or an external 32768 hz crystal, selected by configuration option. to- gether with f sys /4, it is used as a clock source for certain internal functions such as the lcd driver, watchdog timer, buzzer, rtc interrupt and time base interrupt. the lcd clock source is the f sub clock source divided by 8, giving a frequency of 4khz. the internal clock f s ,is simply a choice of either f sub or f sys /4, using a configura - tion option. operating modes after the correct clock source configuration selections are made, overall operation of the chosen clock is achieved using the clkmod register. a combination of the hlclk and idlen bits in the clkmod register and use of the halt instruction determine in which mode the device will be run. the devices can operate in the follow - ing modes.  normal mode f m on, f slow on, f sys =f m , cpu on, f s on, f lcd on/off de- pending upon the lcden bit, f wdt on/off depending upon the wdt configuration option and wdt control register.  slow mode f m on, f slow =f m /2~f m /64, f sys =f slow , cpu on, f s on, f lcd on/off depending upon the lcden bit, f wdt on/off de- pending upon the wdt configuration option and wdt control register. it
s important to note that f slow  100khz for proper mcu operation.  idle mode f m ,f slow ,f sys off, cpu off; f sub on, f s on/off by selecting f sub or f sys /4, f lcd on/off depending upon the lcden bit, f wdt on/off depending upon the wdt configuration option and wdt control register.  sleep mode f m ,f slow ,f sys ,f s ,f lcd off, cpu off; f sub ,f wdt on/off de - pending upon the wdt configuration option and wdt control register.   : - ) 0    $    f  @        / a  f  6 a  f  +           / a       6 a  
     d
    
             f    / a  
     6 a    
     +  -   
             f    / a  
     6 a    
        #     
     
 
         / a      6 a 
     f  +        
  6  % + ! 8 d + + ; d  +    4  +   6  +   /  +   , f  +   f  # 3 1 f  # 0 , f  # / 3 f  #  f  # 1 f  # ,  +    , 6 6 6 6 / / / /  +    / 6 6 / / 6 6 / /  +    6 6 / 6 / 6 / 6 /     % + ! , clock control register  clkmod
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 80 may 21, 2012 power down mode and wake-up power down mode all of the holtek microcontrollers have the ability to enter a power down mode. when the device enters this mode, the normal operating current, will be reduced to an extremely low standby current level. this occurs be - cause when the device enters the power down mode, the system oscillator is stopped which reduces the power consumption to extremely low levels, however, as the device maintains its present internal condition, it can be woken up at a later stage and continue running, without requiring a full reset. this feature is extremely important in application areas where the mcu must have its power supply constantly maintained to keep the device in a known condition but where the power supply capacity is limited such as in battery applications. entering the power down mode there is only one way for the device to enter the power down mode and that is to execute the  halt instruc - tion in the application program. when this instruction is executed, the following will occur:  the system oscillator will stop running and the appli - cation program will stop at the halt instruction.  the data memory contents and registers will maintain their present condition.  the wdt will be cleared and resume counting if the wdt clock source is selected to come from the wdt oscillator. the wdt will stop if its clock source origi- nates from the system clock.  the i/o ports will maintain their present condition.  in the status register, the power down flag, pdf, will be set and the watchdog time-out flag, to, will be cleared. standby current considerations as the main reason for entering the power down mode is to keep the current consumption of the mcu to as low a value as possible, perhaps only in the order of several micro-amps, there are other considerations which must also be taken into account by the circuit designer if the power consumption is to be minimized. special atten - tion must be made to the i/o pins on the device. all high-impedance input pins must be connected to either a fixed high or low level as any floating input pins could create internal oscillations and result in increased cur - rent consumption. this also applies to devices which have different package types, as there may be undonbed pins, which must either be setup as outputs or if setup as inputs must have pull-high resistors con - nected. care must also be taken with the loads, which are connected to i/o pins, which are setup as outputs. these should be placed in a condition in which minimum current is drawn or connected only to external circuits that do not draw current, such as other cmos inputs. also note that additional standby current will also be re - quired if the configuration options have enabled the watchdog timer internal oscillator. wake-up after the system enters the power down mode, it can be woken up from one of various sources listed as follows:  an external reset  an external falling edge on port a  a system interrupt  a wdt overflow if the system is woken up by an external reset, the de - vice will experience a full system reset, however, if the device is woken up by a wdt overflow, a watchdog timer reset will be initiated. although both of these wake-up methods will initiate a reset operation, the ac - tual source of the wake-up can be determined by exam - ining the to and pdf flags. the pdf flag is cleared by a system power-up or executing the clear watchdog timer instructions and is set when executing the  halt instruction. the to flag is set if a wdt time-out occurs, and causes a wake-up that only resets the program counter and stack pointer, the other flags remain in their original status. each pin on port a can be setup via an individual config- uration option to permit a negative transition on the pin to wake-up the system. when a port a pin wake-up oc- curs, the program will resume execution at the instruc- tion following the  halt instruction. if the system is woken up by an interrupt, then two possi- ble situations may occur. the first is where the related interrupt is disabled or the interrupt is enabled but the stack is full, in which case the program will resume exe - cution at the instruction following the  halt instruction. in this situation, the interrupt which woke-up the device will not be immediately serviced, but will rather be ser - viced later when the related interrupt is finally enabled or when a stack level becomes free. the other situation is where the related interrupt is enabled and the stack is not full, in which case the regular interrupt response takes place. if an interrupt request flag is set to 1 be - fore entering the power down mode, the wake-up func - tion of the related interrupt will be disabled. no matter what the source of the wake-up event is, once a wake-up situation occurs, a time period equal to 1024 system clock periods will be required before normal sys - tem operation resumes. however, if the wake-up has originated due to an interrupt, the actual interrupt sub - routine execution will be delayed by an additional one or more cycles. if the wake-up results in the execution of the next instruction following the  halt instruction, this will be executed immediately after the 1024 system clock period delay has ended.
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 81 may 21, 2012 3     + -  4   -  *    d $ +   q  h  % + ! 8 h  k  6 d $ +   q  h  % + ! 8 h  k  / -  *     -  *    d $ +   q  h  % + ! 8 h  k  / d $ +   q  h  % + ! 8 h  k  6 -  *        h d + + ; h       h d + + ; h ; < ; 0  *   4 $  '  6 0     = +  # 4 $  = +  (   4    > ; ? ; 2  '    '  1      @   1  : a . 3    $  =  ) 3 > f    b 0 , 4 3  d l     0 , ; g  8    b f  @  k f  % +   * -  4  f    f f b 0 , 4 3  d l     0 , ; g  8    m b f  @  k  f f . 4 +  -  4  f    f f b 0 , 4 3  d l     0 , ; g  8     b f  @  k  f f % +  b -  4  f    b f  @   k  f  # ,  i  f  # 3 1 r dual clock mode operation   : f  +   d + + ;  7
 f  @  f  0 , 4 3  d l    -   *       +   6 ! "      0 , 4 3  d l       0 , ; g  8   +   /  +   , f  # , b  < < <  f  # 3 1    :   : f  @  # 1 f   7 
  # ! &         /  /   7
 f   7   f + % k  f   7 #  + % 1 * d l   : f  f  @  # 1 f   7 f    f
    
   
   
      b 
  7    
      b 7  l l   b   %        0 , ; g  8  +  -   
        0   1 ! "       ! "      :  $ +   : f  ! "      # :  $ + #   f
    
   
 d
    
        /   ,   /   , '
    ! "         *  '
      f f  f
    
   
 ! "        *   / f   7  f
    
  
 dual clock mode structure
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 82 may 21, 2012 low voltage detector  lvd the low voltage detect internal function provides a means for the user to monitor when the power supply voltage falls below a certain fixed level as specified in the dc characteristics. lvd operation the lvd function must be first enabled via a configura - tion option after which bits 3 and 5 of the rtcc register are used to control the overall function of the lvd. bit 3 is the enable/disable control bit and is known as lvdc, when set low the overall function of the lvd will be dis - abled. bit 5 is the lvd detector output bit and is known as lvdo. under normal operation, and when the power supply voltage is above the specified vlvd value in the dc characteristic section, the lvdo bit will remain at a zero value. if the power supply voltage should fall below this vlvd value then the lvdo bit will change to a high value indicating a low voltage condition. note that the lvdo bit is a read-only bit. by polling the lvdo bit in the rtcc register, the application program can therefore determine the presence of a low voltage condition. after power-on, or after a reset, the lvd will be switched off by clearing the lvdc bit in the rtcc register to zero. note that if the lvd is enabled there will be some power consumption associated with its internal circuitry, how- ever, by clearing the lvdc bit to zero the power can be minimised. it is important not to confuse the lvd with the lvr function. in the lvr function an automatic reset will be generated by the microcontroller , whereas in the lvd function only the lvdo bit will be affected with no influence on other microcontroller functions. there are a range of voltage values, selected using a configuration option, which can be chosen to activate the lvd. watchdog timer the watchdog timer is provided to prevent program malfunctions or sequences from jumping to unknown lo - cations, due to certain uncontrollable external events such as electrical noise. it operates by providing a de - vice reset when the watchdog timer counter overflows. watchdog timer operation the watchdog timer clock source is provided by the in - ternal clock, f s , which is in turn supplied by one of two sources selected by configuration option: f sub or f sys /4. note that if the watchdog timer configuration option has been disabled, then any instruction relating to its op - eration will result in no operation. most of the watchdog timer options, such as en - able/disable, watchdog timer clock source and clear in - struction type are selected using configuration options. in addition to a configuration option to enable the watch - dog timer, there are four bits, wdten3~ wdten0, in the misc register to offer an additional enable control of the watchdog timer. these bits must be set to a specific value of 1010 to disable the watchdog timer. any other values for these bits will keep the watchdog timer en- abled. after power on these bits will have the disabled value of 1010.  %         f
    
  
      +  
+    %  /  '    +    %  ,  '    /     ,       
  f  @  # 1  %    
        
  %
&
   f  +    %   
     = , / 0 # f  b  , / 1 # f  b  , / 2 # f      , / 3 # f  >  , 4  
          f  # ,  f  # , / , b  f  # , / 0 b  f  # , / 1     f  # , / 2  f
   
     
      watchdog timer - . %     $     4  %  ! 8 6  6  %  ! 8 /  $ 6 i  $ 0     %  
           
        -             
   !            % ! 6  %  ! 8 0 /  %  ! 8 ,  %  ! 8 0  % ! /  % ! ,  % ! 0  %  ! 8 , 6  %  ! 8 / /  %  ! 8 6 6 
                    &      watchdog timer software control  misc
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 83 may 21, 2012 one of the wdt clock sources is the internal f sub , which can be sourced from either the 32k_int internal oscilla - tor or the 32768hz oscillator. the 32k_int internal os - cillator has an approximate period of 31.2  s at a supply voltage of 5v. however, it should be noted that this specified internal clock period can vary with vdd, tem - perature and process variations. the 32768hz oscillator is supplied by an external 32768hz crystal. the other watchdog timer clock source option is the f sys /4 clock. whether the watchdog timer clock source is its own in - ternal 32k_int, the 32768hz oscillator or f sys /4, it is di - vided by 2 13 ~2 16 , using configuration option to obtain the required watchdog timer time-out period. the max time out period is when the 2 16 option is selected. this time-out period may vary with temperature, vdd and process variations. as the clear instruction only resets the last stage of the divider chain, for this reason the ac - tual division ratio and corresponding watchdog timer time-out can vary by a factor of two. the exact division ratio depends upon the residual value in the watchdog timer counter before the clear instruction is executed. if the f sys /4 clock is used as the watchdog timer clock source, it should be noted that when the system enters the power down mode, then the instruction clock is stopped and the watchdog timer will lose its protecting purposes. for systems that operate in noisy environ- ments, using the 32k_int rc oscillator is strongly rec- ommended. under normal program operation, a watchdog timer time-out will initialise a device reset and set the status bit to. however, if the system is in the power down mode, when a watchdog timer time-out occurs, the to bit in the status register will be set and only the program counter and stack pointer will be reset. three methods can be adopted to clear the contents of the watchdog timer. the first is an external hardware reset, which means a low level on the res pin, the second is using the watchdog software instructions and the third is via a  halt instruction. clearing the watchdog timer there are two methods of using software instructions to clear the watchdog timer, one of which must be chosen by configuration option. the first option is to use the sin - gle  clr wdt  instruction while the second is to use the two commands  clr wdt1  and  clr wdt2  . for the first option, a simple execution of  clr wdt  will clear the wdt while for the second option, both  clr wdt1  and  clr wdt2  must both be executed to successfully clear the watchdog timer. note that for this second op - tion, if  clr wdt1  is used to clear the watchdog timer, successive executions of this instruction will have no ef - fect, only the execution of a  clr wdt2  instruction will clear the watchdog timer. similarly after the  clr wdt2 instruction has been executed, only a successive  clr wdt1  instruction can clear the watchdog timer. configuration options configuration options refer to certain options within the mcu that are programmed into the device during the program- ming process. during the development process, these options are selected using the ht-ide software development tools. as these options are programmed into the device using the hardware programming tools, once they are selected they cannot be changed later as the application software has no control over the configuration options. all options must be defined for proper system function, the details of which are shown in the table. no. options oscillator options 1 high oscillator type selection - f m 1. external crystal oscillator 2. external rc oscillator 3. externally supplied clock - internal filter on 4. externally supplied clock - internal filter off 2 f sub clock selection: 1. 32768hz external oscillator 2. 32k_int internal oscillator 3f s clock selection: f sub or f sys /4 4 xtal mode selection: 455khz or 1m~12mhz 5 32768hz crystal: enable or disable
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 84 may 21, 2012 no. options pfd options 6 pa3: normal i/o or pfd output 7 pfd clock selection: timer/event counter 0 or timer/event counter 1 buzzer options 8 pa0/pa1: normal i/o or bz/bz or pa0=bz and pa1 as normal i/o 9 buzzer frequency: f s /2 2 ,f s /2 3 ,f s /2 4 ,f s /2 5 ,f s /2 6 ,f s /2 7 ,f s /2 8 ,f s /2 9 time base option 10 time base time-out period: 2 12 /f s ,2 13 /f s ,2 14 /f s ,2 15 /f s , lcd option 11 lcd type: r or c - ht56r67 only watchdog options 12 watchdog timer function: enable or disable 13 clrwdt instructions: 1 or 2 instructions 14 wdt time-out period: 2 12 /f s ~2 13 /f s ,2 13 /f s ~2 14 /f s ,2 14 /f s ~2 15 /f s ,2 15 /f s ~2 16 /f s lvd/lvr options 15 lvd function: enable or disable 16 lvr function: enable or disable 17 lvr/lvd voltage: 2.1v/2.2v or 3.15v/3.3v or 4.2v/4.4v spi options 18 sim pin enable/disable 19 spi_wcol: enable/disable 20 spi_csen: enable/disable, used to enable/disable (1/0) software csen function i 2 c option 21 i 2 c debounce time: no debounce, 1 system clock debounce, 2 system clock debounce pintb option 22 external peripheral interrupt or segment function timer/event counter and external interrupt pins filter option 24 interrupt and timer/event counter input pins internal filter on/off control  applies to all pins lock options 25 lock all 26 partial lock
application circuits application circuit for ht56r67 ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 85 may 21, 2012  $ 6 # 7 9  $ / # 7 9  $ ,  $ 0 #  ' %  $ 1 #    ,  $ 2 #    0  $ 3 b   $ 4   /   ,  
 
   #  ! ) + %     i  7 6 # $ 8 6  7 4 # $ 8 4  % 6 #    6  % 0 #    0 i  % 3 #    6  % 4 #    /  % 1 #  8  6  % 2 #  8  / ) %    (     /   , / ,   % , $    ) $ ( + +     1 4 *  s    s / < 2        /   , . % % 1 4 6 ' f  @  # 1 ) %  1 / ) %   +        0   1   0   1  
 
 / , . / . + % , 6 < /  ' 6 < /  ' 6 < /  ' . + % / . % % .  $ :   0   1 0 1  6 i  4   /   ,  !  #  $ 4 . % % .   6 < /  ' . % %   $     (   6 < / i /  ' / 6 *  i / 6 6 *  0 6 6  6 < 6 /  ' / 8 1 / 1  1      @   , $   + ) $ ( + +     '       
        
 0 b 1       , b   *   
         
   , $   + #   $       % , $    ) $ ( + +     '       
        
 / b  ,       / b   *   
         

application circuit for ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 86 may 21, 2012  $ 6 # 7 9  $ / # 7 9  $ ,  $ 0 #  ' %  $ 1 #    ,  $ 2 #    0  $ 3 i  $ 4   /   ,  
 
   #  ! ) + % # + ! %     . + % . % % i  7 6 # $ 8 6  7 4 # $ 8 4  % 6 #    6  % 0 #    0 i  % 3 #    6  % 4 #    /  % 1 #  8  6  % 2 #  8  / ) %    (     /   ,   / / ,   % , $    ) $ ( + +     1 4 *  s    s / < 2        /   , . % % 1 4 6 ' f  @  # 1 ) %  1 / ) %   +        0   1   0   1  
 
   0   1   , 0 1  !  #  $ 4 . % % .   6 < /  ' . % %   $     (   6 < / i /  ' / 6 *  i / 6 6 *  0 6 6  6 < 6 /  ' / 8 1 / 1  1      @   , $   + ) $ ( + +     '       
        
 0 b 1       , b   *   
         
   , $   + #   $       % , $    ) $ ( + +     '       
        
 / b  ,       / b   *   
         

ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 87 may 21, 2012 instruction set introduction central to the successful operation of any microcontroller is its instruction set, which is a set of pro - gram instruction codes that directs the microcontroller to perform certain operations. in the case of holtek microcontroller , a comprehensive and flexible set of over 60 instructions is provided to enable programmers to implement their application with the minimum of pro - gramming overheads. for easier understanding of the various instruction codes, they have been subdivided into several func - tional groupings. instruction timing most instructions are implemented within one instruc - tion cycle. the exceptions to this are branch, call, or ta - ble read instructions where two instruction cycles are required. one instruction cycle is equal to 4 system clock cycles, therefore in the case of an 8mhz system oscillator, most instructions would be implemented within 0.5  s and branch or call instructions would be im - plemented within 1  s. although instructions which re - quire one more cycle to implement are generally limited to the jmp, call, ret, reti and table read instruc- tions, it is important to realize that any other instructions which involve manipulation of the program counter low register or pcl will also take one more cycle to imple- ment. as instructions which change the contents of the pcl will imply a direct jump to that new address, one more cycle will be required. examples of such instruc- tions would be  clr pcl or  mov pcl, a . for the case of skip instructions, it must be noted that if the re- sult of the comparison involves a skip operation then this will also take one more cycle, if no skip is involved then only one cycle is required. moving and transferring data the transfer of data within the microcontroller program is one of the most frequently used operations. making use of three kinds of mov instructions, data can be transferred from registers to the accumulator and vice-versa as well as being able to move specific imme - diate data directly into the accumulator. one of the most important data transfer applications is to receive data from the input ports and transfer data to the output ports. arithmetic operations the ability to perform certain arithmetic operations and data manipulation is a necessary feature of most microcontroller applications. within the holtek microcontroller instruction set are a range of add and subtract instruction mnemonics to enable the necessary arithmetic to be carried out. care must be taken to en - sure correct handling of carry and borrow data when re - sults exceed 255 for addition and less than 0 for subtraction. the increment and decrement instructions inc, inca, dec and deca provide a simple means of increasing or decreasing by a value of one of the values in the destination specified. logical and rotate operations the standard logical operations such as and, or, xor and cpl all have their own instruction within the holtek microcontroller instruction set. as with the case of most instructions involving data manipulation, data must pass through the accumulator which may involve additional programming steps. in all logical data operations, the zero flag may be set if the result of the operation is zero. another form of logical data manipulation comes from the rotate instructions such as rr, rl, rrc and rlc which provide a simple means of rotating one bit right or left. different rotate instructions exist depending on pro - gram requirements. rotate instructions are useful for serial port programming applications where data can be rotated from an internal register into the carry bit from where it can be examined and the necessary serial bit set high or low. another application where rotate data operations are used is to implement multiplication and division calculations. branches and control transfer program branching takes the form of either jumps to specified locations using the jmp instruction or to a sub- routine using the call instruction. they differ in the sense that in the case of a subroutine call, the program must return to the instruction immediately when the sub - routine has been carried out. this is done by placing a return instruction ret in the subroutine which will cause the program to jump back to the address right after the call instruction. in the case of a jmp instruction, the program simply jumps to the desired location. there is no requirement to jump back to the original jumping off point as in the case of the call instruction. one special and extremely useful set of branch instructions are the conditional branches. here a decision is first made re - garding the condition of a certain data memory or indi - vidual bits. depending upon the conditions, the program will continue with the next instruction or skip over it and jump to the following instruction. these instructions are the key to decision making and branching within the pro - gram perhaps determined by the condition of certain in - put switches or by the condition of internal data bits.
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 88 may 21, 2012 bit operations the ability to provide single bit operations on data mem - ory is an extremely flexible feature of all holtek microcontrollers . this feature is especially useful for output port bit programming where individual bits or port pins can be directly set high or low using either the set [m].i or  clr [m].i instructions respectively. the fea - ture removes the need for programmers to first read the 8-bit output port, manipulate the input data to ensure that other bits are not changed and then output the port with the correct new data. this read-modify-write pro - cess is taken care of automatically when these bit oper - ation instructions are used. table read operations data storage is normally implemented by using regis - ters. however, when working with large amounts of fixed data, the volume involved often makes it inconve - nient to store the fixed data in the data memory. to over - come this problem, holtek microcontrollers allow an area of program memory to be setup as a table where data can be directly stored. a set of easy to use instruc - tions provides the means by which this fixed data can be referenced and retrieved from the program memory. other operations in addition to the above functional instructions, a range of other instructions also exist such as the  halt in - struction for power-down operations and instructions to control the operation of the watchdog timer for reliable program operations under extreme electric or electro - magnetic environments. for their relevant operations, refer to the functional related sections. instruction set summary the following table depicts a summary of the instruction set categorised according to function and can be con - sulted as a basic instruction reference using the follow - ing listed conventions. table conventions: x: bits immediate data m: data memory address a: accumulator i: 0~7 number of bits addr: program memory address mnemonic description cycles flag affected arithmetic add a,[m] addm a,[m] add a,x adc a,[m] adcm a,[m] sub a,x sub a,[m] subm a,[m] sbc a,[m] sbcm a,[m] daa [m] add data memory to acc add acc to data memory add immediate data to acc add data memory to acc with carry add acc to data memory with carry subtract immediate data from the acc subtract data memory from acc subtract data memory from acc with result in data memory subtract data memory from acc with carry subtract data memory from acc with carry, result in data memory decimal adjust acc for addition with result in data memory 1 1 note 1 1 1 note 1 1 1 note 1 1 note 1 note z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov c logic operation and a,[m] or a,[m] xor a,[m] andm a,[m] orm a,[m] xorm a,[m] and a,x or a,x xor a,x cpl [m] cpla [m] logical and data memory to acc logical or data memory to acc logical xor data memory to acc logical and acc to data memory logical or acc to data memory logical xor acc to data memory logical and immediate data to acc logical or immediate data to acc logical xor immediate data to acc complement data memory complement data memory with result in acc 1 1 1 1 note 1 note 1 note 1 1 1 1 note 1 z z z z z z z z z z z increment & decrement inca [m] inc [m] deca [m] dec [m] increment data memory with result in acc increment data memory decrement data memory with result in acc decrement data memory 1 1 note 1 1 note z z z z
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 89 may 21, 2012 mnemonic description cycles flag affected rotate rra [m] rr [m] rrca [m] rrc [m] rla [m] rl [m] rlca [m] rlc [m] rotate data memory right with result in acc rotate data memory right rotate data memory right through carry with result in acc rotate data memory right through carry rotate data memory left with result in acc rotate data memory left rotate data memory left through carry with result in acc rotate data memory left through carry 1 1 note 1 1 note 1 1 note 1 1 note none none c c none none c c data move mov a,[m] mov [m],a mov a,x move data memory to acc move acc to data memory move immediate data to acc 1 1 note 1 none none none bit operation clr [m].i set [m].i clear bit of data memory set bit of data memory 1 note 1 note none none branch jmp addr sz [m] sza [m] sz [m].i snz [m].i siz [m] sdz [m] siza [m] sdza [m] call addr ret ret a,x reti jump unconditionally skip if data memory is zero skip if data memory is zero with data movement to acc skip if bit i of data memory is zero skip if bit i of data memory is not zero skip if increment data memory is zero skip if decrement data memory is zero skip if increment data memory is zero with result in acc skip if decrement data memory is zero with result in acc subroutine call return from subroutine return from subroutine and load immediate data to acc return from interrupt 2 1 note 1 note 1 note 1 note 1 note 1 note 1 note 1 note 2 2 2 2 none none none none none none none none none none none none none table read tabrdc [m] tabrdl [m] read table (current page) to tblh and data memory read table (last page) to tblh and data memory 2 note 2 note none none miscellaneous nop clr [m] set [m] clr wdt clr wdt1 clr wdt2 swap [m] swapa [m] halt no operation clear data memory set data memory clear watchdog timer pre-clear watchdog timer pre-clear watchdog timer swap nibbles of data memory swap nibbles of data memory with result in acc enter power down mode 1 1 note 1 note 1 1 1 1 note 1 1 none none none to, pdf to, pdf to, pdf none none to, pdf note: 1. for skip instructions, if the result of the comparison involves a skip then two cycles are required, if no skip takes place only one cycle is required. 2. any instruction which changes the contents of the pcl will also require 2 cycles for execution. 3. for the  clr wdt1 and  clr wdt2 instructions the to and pdf flags may be affected by the execution status. the to and pdf flags are cleared after both  clr wdt1 and  clr wdt2 instructions are consecutively executed. otherwise the to and pdf flags remain unchanged.
instruction definition adc a,[m] add data memory to acc with carry description the contents of the specified data memory, accumulator and the carry flag are added. the result is stored in the accumulator. operation acc  acc+[m]+c affected flag(s) ov, z, ac, c adcm a,[m] add acc to data memory with carry description the contents of the specified data memory, accumulator and the carry flag are added. the result is stored in the specified data memory. operation [m]  acc+[m]+c affected flag(s) ov, z, ac, c add a,[m] add data memory to acc description the contents of the specified data memory and the accumulator are added. the result is stored in the accumulator. operation acc  acc + [m] affected flag(s) ov, z, ac, c add a,x add immediate data to acc description the contents of the accumulator and the specified immediate data are added. the result is stored in the accumulator. operation acc  acc+x affected flag(s) ov, z, ac, c addm a,[m] add acc to data memory description the contents of the specified data memory and the accumulator are added. the result is stored in the specified data memory. operation [m]  acc + [m] affected flag(s) ov, z, ac, c and a,[m] logical and data memory to acc description data in the accumulator and the specified data memory perform a bitwise logical and op - eration. the result is stored in the accumulator. operation acc  acc and [m] affected flag(s) z and a,x logical and immediate data to acc description data in the accumulator and the specified immediate data perform a bitwise logical and operation. the result is stored in the accumulator. operation acc  acc and x affected flag(s) z andm a,[m] logical and acc to data memory description data in the specified data memory and the accumulator perform a bitwise logical and op - eration. the result is stored in the data memory. operation [m]  acc and [m] affected flag(s) z ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 90 may 21, 2012
call addr subroutine call description unconditionally calls a subroutine at the specified address. the program counter then in - crements by 1 to obtain the address of the next instruction which is then pushed onto the stack. the specified address is then loaded and the program continues execution from this new address. as this instruction requires an additional operation, it is a two cycle instruc - tion. operation stack  program counter + 1 program counter  addr affected flag(s) none clr [m] clear data memory description each bit of the specified data memory is cleared to 0. operation [m]  00h affected flag(s) none clr [m].i clear bit of data memory description bit i of the specified data memory is cleared to 0. operation [m].i  0 affected flag(s) none clr wdt clear watchdog timer description the to, pdf flags and the wdt are all cleared. operation wdt cleared to  0 pdf  0 affected flag(s) to, pdf clr wdt1 pre-clear watchdog timer description the to, pdf flags and the wdt are all cleared. note that this instruction works in conjunc- tion with clr wdt2 and must be executed alternately with clr wdt2 to have effect. re- petitively executing this instruction without alternately executing clr wdt2 will have no effect. operation wdt cleared to  0 pdf  0 affected flag(s) to, pdf clr wdt2 pre-clear watchdog timer description the to, pdf flags and the wdt are all cleared. note that this instruction works in conjunc - tion with clr wdt1 and must be executed alternately with clr wdt1 to have effect. re - petitively executing this instruction without alternately executing clr wdt1 will have no effect. operation wdt cleared to  0 pdf  0 affected flag(s) to, pdf ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 91 may 21, 2012
cpl [m] complement data memory description each bit of the specified data memory is logically complemented (1
s complement). bits which previously contained a 1 are changed to 0 and vice versa. operation [m]  [m] affected flag(s) z cpla [m] complement data memory with result in acc description each bit of the specified data memory is logically complemented (1
s complement). bits which previously contained a 1 are changed to 0 and vice versa. the complemented result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc  [m] affected flag(s) z daa [m] decimal-adjust acc for addition with result in data memory description convert the contents of the accumulator value to a bcd ( binary coded decimal) value re - sulting from the previous addition of two bcd variables. if the low nibble is greater than 9 or if ac flag is set, then a value of 6 will be added to the low nibble. otherwise the low nibble remains unchanged. if the high nibble is greater than 9 or if the c flag is set, then a value of 6 will be added to the high nibble. essentially, the decimal conversion is performed by add - ing 00h, 06h, 60h or 66h depending on the accumulator and flag conditions. only the c flag may be affected by this instruction which indicates that if the original bcd sum is greater than 100, it allows multiple precision decimal addition. operation [m]  acc + 00h or [m]  acc + 06h or [m]  acc + 60h or [m]  acc + 66h affected flag(s) c dec [m] decrement data memory description data in the specified data memory is decremented by 1. operation [m]  [m]  1 affected flag(s) z deca [m] decrement data memory with result in acc description data in the specified data memory is decremented by 1. the result is stored in the accu - mulator. the contents of the data memory remain unchanged. operation acc  [m]  1 affected flag(s) z halt enter power down mode description this instruction stops the program execution and turns off the system clock. the contents of the data memory and registers are retained. the wdt and prescaler are cleared. the power down flag pdf is set and the wdt time-out flag to is cleared. operation to  0 pdf  1 affected flag(s) to, pdf ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 92 may 21, 2012
inc [m] increment data memory description data in the specified data memory is incremented by 1. operation [m]  [m]+1 affected flag(s) z inca [m] increment data memory with result in acc description data in the specified data memory is incremented by 1. the result is stored in the accumu - lator. the contents of the data memory remain unchanged. operation acc  [m]+1 affected flag(s) z jmp addr jump unconditionally description the contents of the program counter are replaced with the specified address. program execution then continues from this new address. as this requires the insertion of a dummy instruction while the new address is loaded, it is a two cycle instruction. operation program counter  addr affected flag(s) none mov a,[m] move data memory to acc description the contents of the specified data memory are copied to the accumulator. operation acc  [m] affected flag(s) none mov a,x move immediate data to acc description the immediate data specified is loaded into the accumulator. operation acc  x affected flag(s) none mov [m],a move acc to data memory description the contents of the accumulator are copied to the specified data memory. operation [m]  acc affected flag(s) none nop no operation description no operation is performed. execution continues with the next instruction. operation no operation affected flag(s) none or a,[m] logical or data memory to acc description data in the accumulator and the specified data memory perform a bitwise logical or oper - ation. the result is stored in the accumulator. operation acc  acc or [m] affected flag(s) z ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 93 may 21, 2012
or a,x logical or immediate data to acc description data in the accumulator and the specified immediate data perform a bitwise logical or op - eration. the result is stored in the accumulator. operation acc  acc or x affected flag(s) z orm a,[m] logical or acc to data memory description data in the specified data memory and the accumulator perform a bitwise logical or oper - ation. the result is stored in the data memory. operation [m]  acc or [m] affected flag(s) z ret return from subroutine description the program counter is restored from the stack. program execution continues at the re - stored address. operation program counter  stack affected flag(s) none ret a,x return from subroutine and load immediate data to acc description the program counter is restored from the stack and the accumulator loaded with the specified immediate data. program execution continues at the restored address. operation program counter  stack acc  x affected flag(s) none reti return from interrupt description the program counter is restored from the stack and the interrupts are re-enabled by set- ting the emi bit. emi is the master interrupt global enable bit. if an interrupt was pending when the reti instruction is executed, the pending interrupt routine will be processed be- fore returning to the main program. operation program counter  stack emi  1 affected flag(s) none rl [m] rotate data memory left description the contents of the specified data memory are rotated left by 1 bit with bit 7 rotated into bit 0. operation [m].(i+1)  [m].i; (i = 0~6) [m].0  [m].7 affected flag(s) none rla [m] rotate data memory left with result in acc description the contents of the specified data memory are rotated left by 1 bit with bit 7 rotated into bit 0. the rotated result is stored in the accumulator and the contents of the data memory re - main unchanged. operation acc.(i+1)  [m].i; (i = 0~6) acc.0  [m].7 affected flag(s) none ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 94 may 21, 2012
rlc [m] rotate data memory left through carry description the contents of the specified data memory and the carry flag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry flag is rotated into bit 0. operation [m].(i+1)  [m].i; (i = 0~6) [m].0  c c  [m].7 affected flag(s) c rlca [m] rotate data memory left through carry with result in acc description data in the specified data memory and the carry flag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry flag is rotated into the bit 0. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.(i+1)  [m].i; (i = 0~6) acc.0  c c  [m].7 affected flag(s) c rr [m] rotate data memory right description the contents of the specified data memory are rotated right by 1 bit with bit 0 rotated into bit 7. operation [m].i  [m].(i+1); (i = 0~6) [m].7  [m].0 affected flag(s) none rra [m] rotate data memory right with result in acc description data in the specified data memory and the carry flag are rotated right by 1 bit with bit 0 ro- tated into bit 7. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.i  [m].(i+1); (i = 0~6) acc.7  [m].0 affected flag(s) none rrc [m] rotate data memory right through carry description the contents of the specified data memory and the carry flag are rotated right by 1 bit. bit 0 replaces the carry bit and the original carry flag is rotated into bit 7. operation [m].i  [m].(i+1); (i = 0~6) [m].7  c c  [m].0 affected flag(s) c rrca [m] rotate data memory right through carry with result in acc description data in the specified data memory and the carry flag are rotated right by 1 bit. bit 0 re - places the carry bit and the original carry flag is rotated into bit 7. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.i  [m].(i+1); (i = 0~6) acc.7  c c  [m].0 affected flag(s) c ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 95 may 21, 2012
sbc a,[m] subtract data memory from acc with carry description the contents of the specified data memory and the complement of the carry flag are sub - tracted from the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc  acc  [m]  c affected flag(s) ov, z, ac, c sbcm a,[m] subtract data memory from acc with carry and result in data memory description the contents of the specified data memory and the complement of the carry flag are sub - tracted from the accumulator. the result is stored in the data memory. note that if the re - sult of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation [m]  acc  [m]  c affected flag(s) ov, z, ac, c sdz [m] skip if decrement data memory is 0 description the contents of the specified data memory are first decremented by 1. if the result is 0 the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation [m]  [m]  1 skip if [m] = 0 affected flag(s) none sdza [m] skip if decrement data memory is zero with result in acc description the contents of the specified data memory are first decremented by 1. if the result is 0, the following instruction is skipped. the result is stored in the accumulator but the specified data memory contents remain unchanged. as this requires the insertion of a dummy in- struction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0, the program proceeds with the following instruction. operation acc  [m]  1 skip if acc = 0 affected flag(s) none set [m] set data memory description each bit of the specified data memory is set to 1. operation [m]  ffh affected flag(s) none set [m].i set bit of data memory description bit i of the specified data memory is set to 1. operation [m].i  1 affected flag(s) none ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 96 may 21, 2012
siz [m] skip if increment data memory is 0 description the contents of the specified data memory are first incremented by 1. if the result is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation [m]  [m]+1 skip if [m] = 0 affected flag(s) none siza [m] skip if increment data memory is zero with result in acc description the contents of the specified data memory are first incremented by 1. if the result is 0, the following instruction is skipped. the result is stored in the accumulator but the specified data memory contents remain unchanged. as this requires the insertion of a dummy in - struction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation acc  [m]+1 skip if acc = 0 affected flag(s) none snz [m].i skip if bit i of data memory is not 0 description if bit i of the specified data memory is not 0, the following instruction is skipped. as this re - quires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is 0 the program proceeds with the following instruction. operation skip if [m].i  0 affected flag(s) none sub a,[m] subtract data memory from acc description the specified data memory is subtracted from the contents of the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc  acc  [m] affected flag(s) ov, z, ac, c subm a,[m] subtract data memory from acc with result in data memory description the specified data memory is subtracted from the contents of the accumulator. the result is stored in the data memory. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation [m]  acc  [m] affected flag(s) ov, z, ac, c sub a,x subtract immediate data from acc description the immediate data specified by the code is subtracted from the contents of the accumu - lator. the result is stored in the accumulator. note that if the result of subtraction is nega - tive, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc  acc  x affected flag(s) ov, z, ac, c ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 97 may 21, 2012
swap [m] swap nibbles of data memory description the low-order and high-order nibbles of the specified data memory are interchanged. operation [m].3~[m].0  [m].7 ~ [m].4 affected flag(s) none swapa [m] swap nibbles of data memory with result in acc description the low-order and high-order nibbles of the specified data memory are interchanged. the result is stored in the accumulator. the contents of the data memory remain unchanged. operation acc.3 ~ acc.0  [m].7 ~ [m].4 acc.7 ~ acc.4  [m].3 ~ [m].0 affected flag(s) none sz [m] skip if data memory is 0 description if the contents of the specified data memory is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruc - tion. operation skip if [m] = 0 affected flag(s) none sza [m] skip if data memory is 0 with data movement to acc description the contents of the specified data memory are copied to the accumulator. if the value is zero, the following instruction is skipped. as this requires the insertion of a dummy instruc - tion while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation acc  [m] skip if [m] = 0 affected flag(s) none sz [m].i skip if bit i of data memory is 0 description if bit i of the specified data memory is 0, the following instruction is skipped. as this re- quires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0, the program proceeds with the following instruction. operation skip if [m].i = 0 affected flag(s) none tabrdc [m] read table (current page) to tblh and data memory description the low byte of the program code (current page) addressed by the table pointer (tblp) is moved to the specified data memory and the high byte moved to tblh. operation [m]  program code (low byte) tblh  program code (high byte) affected flag(s) none tabrdl [m] read table (last page) to tblh and data memory description the low byte of the program code (last page) addressed by the table pointer (tblp) is moved to the specified data memory and the high byte moved to tblh. operation [m]  program code (low byte) tblh  program code (high byte) affected flag(s) none ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 98 may 21, 2012
xor a,[m] logical xor data memory to acc description data in the accumulator and the specified data memory perform a bitwise logical xor op - eration. the result is stored in the accumulator. operation acc  acc xor [m] affected flag(s) z xorm a,[m] logical xor acc to data memory description data in the specified data memory and the accumulator perform a bitwise logical xor op - eration. the result is stored in the data memory. operation [m]  acc xor [m] affected flag(s) z xor a,x logical xor immediate data to acc description data in the accumulator and the specified immediate data perform a bitwise logical xor operation. the result is stored in the accumulator. operation acc  acc xor x affected flag(s) z ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 99 may 21, 2012
package information note that the package information provided here is for consultation purposes only. as this information may be updated at regu - lar intervals users are reminded to consult the holtek website ( http://www.holtek.com.tw/english/literature/package.pdf ) for the latest version of the package information. 52-pin qfp (14mm  14mm) outline dimensions symbol dimensions in inch min. nom. max. a 0.681  0.689 b 0.547  0.555 c 0.681  0.689 d 0.547  0.555 e  0.039  f  0.016  g 0.098  0.122 h  0.134 i  0.004  j 0.029  0.041 k 0.004  0.008  07 symbol dimensions in mm min. nom. max. a 17.30  17.50 b 13.90  14.10 c 17.30  17.50 d 13.90  14.10 e  1.00  f  0.40  g 2.50  3.10 h  3.40 i  0.10  j 0.73  1.03 k 0.10  0.20  07 ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 100 may 21, 2012          
          
64-pin lqfp (7mm  7mm) outline dimensions symbol dimensions in inch min. nom. max. a 0.350  0.358 b 0.272  0.280 c 0.350  0.358 d 0.272  0.280 e  0.016  f 0.005  0.009 g 0.053  0.057 h  0.063 i 0.002  0.006 j 0.018  0.030 k 0.004  0.008  07 symbol dimensions in mm min. nom. max. a 8.90  9.10 b 6.90  7.10 c 8.90  9.10 d 6.90  7.10 e  0.40  f 0.13  0.23 g 1.35  1.45 h  1.60 i 0.05  0.15 j 0.45  0.75 k 0.09  0.20  07 ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 101 may 21, 2012 1  1 5 0 0 0 , 3 1 / / 3 / 4 $ 7 % ! ' ) d  t ;
100-pin lqfp (14mm  14mm) outline dimensions symbol dimensions in inch min. nom. max. a 0.626  0.634 b 0.547  0.555 c 0.626  0.634 d 0.547  0.555 e  0.020  f  0.008  g 0.053  0.057 h  0.063 i  0.004  j 0.018  0.030 k 0.004  0.008  07 symbol dimensions in mm min. nom. max. a 15.90  16.10 b 13.90  14.10 c 15.90  16.10 d 13.90  14.10 e  0.50  f  0.20  g 1.35  1.45 h  1.60 i  0.10  j 0.45  0.75 k 0.10  0.20  07 ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 102 may 21, 2012 / 6 6 / , 2 $ 7 % 2 6 , 3 ! ' ) d  t ; 2 / 4 2 4 3
128-pin qfp (14mm  20mm) outline dimensions symbol dimensions in inch min. nom. max. a 0.669  0.689 b 0.547  0.555 c 0.906  0.925 d 0.783  0.791 e  0.020  f  0.008  g 0.098  0.122 h  0.134 i  0.004  j 0.026  0.037 k 0.004  0.008  07 symbol dimensions in mm min. nom. max. a 17.00  17.50 b 13.90  14.10 c 23.00  23.50 d 19.90  20.10 e  0.50  f  0.20  g 2.50  3.10 h  3.40 i  0.10  j 0.65  0.95 k 0.10  0.20  07 ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 103 may 21, 2012 / 6 0 / ,  / 0  0 5 $ 7 / 6 , 3 2 % ! ' ) d  t ; 3 1
ht56r67/ht56r668/ht56c668/ht56r678/ht56c678/ht56r688 rev. 1.60 104 may 21, 2012 copyright  2012 by holtek semiconductor inc. the information appearing in this data sheet is believed to be accurate at the time of publication. however, holtek as - sumes no responsibility arising from the use of the specifications described. the applications mentioned herein are used solely for the purpose of illustration and holtek makes no warranty or representation that such applications will be suitable without further modification, nor recommends the use of its products for application that may present a risk to human life due to malfunction or otherwise. holtek  s products are not authorized for use as critical components in life support devices or systems. holtek reserves the right to alter its products without prior notification. for the most up-to-date information, please visit our web site at http://www.holtek.com.tw. holtek semiconductor inc. (headquarters) no.3, creation rd. ii, science park, hsinchu, taiwan tel: 886-3-563-1999 fax: 886-3-563-1189 http://www.holtek.com.tw holtek semiconductor inc. (taipei sales office) 4f-2, no. 3-2, yuanqu st., nankang software park, taipei 115, taiwan tel: 886-2-2655-7070 fax: 886-2-2655-7373 fax: 886-2-2655-7383 (international sales hotline) holtek semiconductor inc. (shenzhen sales office) 5f, unit a, productivity building, no.5 gaoxin m 2nd road, nanshan district, shenzhen, china 518057 tel: 86-755-8616-9908, 86-755-8616-9308 fax: 86-755-8616-9722 holtek semiconductor (usa), inc. (north america sales office) 46729 fremont blvd., fremont, ca 94538, usa tel: 1-510-252-9880 fax: 1-510-252-9885 http://www.holtek.com


▲Up To Search▲   

 
Price & Availability of HT56R67812

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X